How to Get Rid of Gnats in Potting Soil
A gnat can lay 200 to 300 eggs in its short lifetime, which means that if you have a houseplant that has a gnat problem, in short order your entire house could have a gnat problem. Gnats often infest the potting soil in houseplants because the warm, humid conditions that make the plants so happy are also paradise for the gnat. Fortunately, knowing the source of your problem will make eradicating these annoying insects much easier.
Make a gnat trap. Use a hammer and nail to punch small holes in the lid of a mason jar. Fill the jar two-thirds of the way with vinegar, then put the lid on the jar. The gnats will crawl into the holes to get to the vinegar, then be unable to crawl back out. Place the trap near your plant to get rid of the gnats that have already hatched and are creating a problem and prevent them from laying a new generation.
Replace the plant's soil with sterile potting soil. This will help limit the larvae that are left on the plant or in the pot. Gently remove the plant and shake the soil free. Dispose of it completely rather than just dumping it outside. You may want to rinse the roots of the plant as well.
Cover the top of the potting soil with peat moss. This will deter the existing gnats from laying more eggs on the soil.
Change your plant-care habits. Watering your plant less frequently will help make the soil less attractive to gnats, which cannot hatch if soil is not moist. Also, make sure that the drainage in the pot is effective. If the water is sitting in the soil and making mud, you are more likely to get a gnat infestation.