The gnats you see in and around your drain could be one of many different small flies. Fungus gnats, for example, typically breed in soggy soil in container plants. Fruit flies are drawn by ripening fruit and the recycling bin. Drain flies begin in the sewers and emerge from the drain into the home. These species of small flies and other gnats can be controlled and removed by incorporating several removal methods.
Remove whatever is attracting the gnats, such as empty soda bottles, ripening fruit or soggy potting soil in your container plants. This will help stop the gnats from returning once you get rid of them.
Set out traps. Commercial fly traps are available, but you can also make your own. Smear petroleum jelly on yellow cardboard strips and hang them near the drain and other places where you notice the gnats. For fruit flies, Barb Ogg of the University of Nebraska--Lincoln Extension suggests filling a jar or container with approximately 1 inch of beer and securing the top with plastic forming a small funnel into the jar. Use a rubber band to make it tight and secure. Poke several holes in it, so the flies can fly through it, with a sharp knife or another sharp object.
Pour a gallon of boiling water into your drain to help kill most of the gnats, maggots and eggs in your drain.
Mix 1 cup of chlorine bleach with 5 cups of water. Pour it down your drain to kill the gnats, maggots and eggs further down the drain where the boiling water could not reach.
Pour 1 tbsp. of vegetable oil down your drain at night, as recommended by Ogg, to create a thin layer of oil on the surface of the water that settles at the bottom of the drain where the gnats, usually fruit flies, are breeding.