If you are trying to get rid of gnats in your terrarium, start with the soil, not the flying adults. The tiny flies are usually fungus gnats, and their larvae develop in moist growing media where they feed on fungi, algae, decaying organic material, and sometimes fine plant roots.
The adults are mostly a nuisance, but swatting the flies you can see will not solve the problem. To break the cycle, reduce constantly wet conditions that favor the larvae, remove decaying material, trap some adults, and treat the growing medium only if the simpler steps aren’t enough.
Are Those Tiny Flies Really Fungus Gnats?
Fungus gnats are small, dark flies with long legs and clear wings. Colorado State University Extension describes the adults as delicate, mosquito-like flies commonly found around houseplants. They are weak fliers and often stay close to damp growing media.
Fruit flies are different. They are usually tan or light brown and are strongly associated with fermenting fruit, vegetables, beverages, and other sugary material. If the flies keep hovering around a plant-only terrarium instead of the fruit bowl or kitchen trash, fungus gnats are the more likely suspect.
Yellow sticky traps can help confirm that small flying insects are present, but identification still matters. Different small flies breed in different materials, so the best control starts by finding the breeding site.
How Do Fungus Gnats Get Into a Terrarium?
They can arrive with plants, potting mix, moss, or other damp organic material. Fungus gnat eggs and larvae are small enough to go unnoticed, and adults are attracted to moist growing media where they can lay eggs.
UC Statewide IPM notes that organic growing media can already contain fungus gnats if it becomes wet before use or is stored uncovered. A terrarium can therefore start with eggs or larvae already in the substrate, even if you never saw an adult fly during assembly.
Adults can also enter while you water, prune, or clean an open terrarium. Once moist soil and fungal growth are available, the terrarium can become a breeding site.
Why Are Tiny Flies Trapped Under My Terrarium Lid?
If tiny flies appear inside a closed terrarium, they may have developed from eggs or larvae already in the growing medium before you closed the lid. Adult fungus gnats emerge from the soil after completing their larval and pupal stages.
That explains why a terrarium can seem fine for days and then suddenly have little flies walking or flying against the glass. The adults may not have squeezed through a sealed lid; they may have completed their life cycle inside the container.
Open the terrarium carefully and deal with the breeding conditions in the soil. Releasing the visible adults alone does not remove eggs and larvae that may still be developing below.
How to Get Rid of Gnats in Your Terrarium
A terrarium needs a little more care than an ordinary flowerpot because many terrarium plants prefer humidity and evenly moist soil. The goal is not to dry the plants until they wilt. The goal is to stop keeping the growing medium wetter than the plants actually need.
- Open the terrarium if it is closed. Let excess condensation and surface moisture escape.
- Stop adding water until the growing mix actually needs it. Check the soil instead of watering on a calendar.
- Remove fallen leaves, dead roots, rotting wood, and other decaying material that can support fungi and fungus gnat larvae.
- Place a small yellow sticky trap near the terrarium opening or just above the soil where it will not stick to plant leaves. Use it to catch and monitor adult gnats.
- Watch the soil surface. If it remains constantly wet, continue airing the terrarium and lengthen the time between waterings while keeping the plants within their normal moisture needs.
- If the problem continues, consider a Bacillus thuringiensis var. israelensis (Bti) product specifically labeled for fungus gnat larvae and indoor plants. Follow the product label exactly.
- For a severe, persistent infestation, removing the plants and rebuilding with clean materials and fresh growing mix may be easier than repeatedly treating the same wet substrate.
University of Minnesota, Colorado State, Illinois, Maryland, and New Hampshire Extension all emphasize moisture management as central to fungus gnat control. The adults are easy to notice, but the larvae in the growing medium are the part of the life cycle you need to interrupt.
Can Sticky Traps Help With Terrarium Fungus Gnats?
Yes, but sticky traps are only part of the solution. Yellow sticky cards attract and catch adult fungus gnats, so they help monitor the infestation and reduce some egg-laying adults.
University of Minnesota Extension warns that sticky traps should not be the only control method because the larvae remain in the growing medium. Colorado State makes the same distinction: adult traps can reduce numbers, but larval control and moisture management are more important for breaking the cycle.
For a small terrarium, you do not need a large greenhouse card. A small yellow sticky tab placed near the opening or above the substrate can work, as long as it does not touch leaves, moss, pets, or anything else that could stick to it.
Can Mesh Vents Keep Fungus Gnats Out of a Terrarium?
Fine mesh can help keep new adults from entering a ventilated terrarium, but it will not cure an infestation already inside.
UC Statewide IPM notes that sufficiently fine mesh can exclude egg-laying fungus gnat adults from covered growing areas. The same basic idea can help with terrarium vents or openings.
Mesh has limits, though. Fungus gnats can arrive in damp potting mix or plant material, and a screen won’t affect eggs or larvae already in the terrarium. Use mesh as an exclusion step, not as a replacement for clean materials and proper moisture control.
Do not seal ventilation so tightly that you create a new humidity or heat problem for the plants. The terrarium still needs conditions that match the species growing inside it.
What If the Gnats Keep Coming Back?
Repeated fungus gnats usually mean the breeding conditions are still present. Constantly wet soil, algae, fungi, dead leaves, and decomposing organic material give the larvae food and moisture.
To understand why moisture can linger in a closed container, see our guide on how a terrarium works.
University of Maryland Extension notes that algae and fungal growth on potting media can attract fungus gnats. If the soil surface has a green mat or heavy fungal growth, correct that problem along with the insects. See How to Get Rid of Algae in Your Terrarium for an algae-cleanup routine.
If changing the watering pattern does not make a difference after a few weeks, inspect the substrate more closely. Old growing media can break down and hold too much water. Colorado State Extension recommends repotting with fresh soil when potting media has degraded and stays excessively moist.
A potato slice placed on the soil can also help you check for larvae. University of Minnesota and Colorado State both describe potato pieces as a monitoring tool because fungus gnat larvae are attracted to them.
Can Fruit Flies Breed in a Terrarium?
Usually not in a normal plant terrarium. Fruit flies breed in fermenting fruit, vegetables, beverages, and other yeast-rich material. Colorado State and the University of Minnesota Extension both distinguish them from fungus gnats, which commonly breed in moist houseplant soil.
If a terrarium contains fruit, sugary food, or another fermenting material, fruit flies could use it. That is more likely in an animal enclosure where food is offered than in a plant-only terrarium.
If the flies are coming from the soil and the terrarium stays damp, fungus gnats are the better first suspect. If the flies are concentrated around fruit or food scraps, investigate fruit flies instead.
How to Prevent Gnats in a New Terrarium
- Start with clean containers, tools, and healthy plants.
- Use fresh growing media and keep unused potting mix dry and covered.
- Do not add more water than the terrarium needs.
- Remove dead leaves and other decaying material during routine maintenance.
- Avoid letting water collect in the bottom of the container.
- Watch for algae or fungal growth on the soil surface.
- Inspect new plants before adding them to an established terrarium.
- Use fine mesh on ventilation openings when practical, but do not rely on mesh alone.
- Set a small yellow sticky trap nearby when you suspect a problem so you can catch adults early.
Prevention is mostly about moisture, sanitation, and clean starting materials. A humid terrarium is not automatically a fungus gnat terrarium. Problems develop when the growing medium stays continuously wet, and there is plenty of fungal or decaying material for larvae to feed on.
The Bottom Line
To get rid of gnats in your terrarium, focus on the damp growing medium where fungus gnat larvae develop. Air out an overly wet container, reduce unnecessary watering, remove decaying material, and use yellow sticky traps to catch and monitor adults.
If the infestation persists, a Bti product labeled for fungus gnat larvae and indoor plants can target the larval stage. Fine mesh can help prevent new adults from entering, but it will not remove eggs or larvae already in the terrarium.
Once you control moisture and breeding conditions, the adult flies should disappear because you’ve interrupted their life cycle.
Until next time.
Browse more Terrarium guides.
Sources and Further Reading
- University of Maryland Extension – Fungus Gnats
- University of Minnesota Extension – Managing Insects on Indoor Plants
- Colorado State University Extension – Fungus Gnats as Houseplant and Indoor Pests
- University of New Hampshire Extension – Fungus Gnats
- UC Statewide IPM Program – Fungus Gnats
- Colorado State University Extension – Flies in the Home
- University of Maryland Extension – Algae and Fungal Growth on the Soil of Indoor Plants
