If you see gnats buzzing around your favorite houseplants, they're actually sciarid flies. These fruit fly-like insects thrive in warm, damp conditions, such as the top layer of soil in a flowerpot or potted plant. Sciarid flies may be a nuisance, but they won't actually hurt your plant or its root structure. Still, they're not attractive to have in your home, so you'll want to take steps to avoid them.
Don't over water. Keep the top 1 inch of your soil dry to discourage gnats to lay their eggs in the moist, decomposing material. Bottom watering can help with this. Bottom water by placing your plant's container in water until it's absorbed enough water to wet the bottom two-thirds of the soil. Check by sticking your finger into the soil.
Cover the top of the soil in your plant's pot with decorative gravel. Make it more difficult for gnats to find and reproduce in your soil's moist conditions by hiding the top layer under this new dry layer.
Don't leave your pot in standing water, such as in a self-watering pot or a drainage container. Allow your plant to absorb enough water to make the soil damp but not wet and then drain off the excess.
Clean your plant's containers. Remove any dead or decaying leaves or flower pieces because gnats feed on this type of material. Rinse out the saucers that catch excess water on a regular basis.
Increase air flow around your plants. Gnats are less likely to be attracted to soil if the top layer is dry, and fans and open windows can help speed the evaporation of surface water.
Water occasionally with a diluted insecticide. Use this as a precautionary measure if you have other plants that are infested with gnats. This will make the soil inhospitable to your winged visitors.
Avoid repotting your plant because gnats can hide deep in the soil and throughout your plant's root structure.