Gnats are pesky little flying insects that love to hover around food, more specifically, fruit. It can be hard to get rid of gnats because the little buggers constantly seem to multiply, but with a few tips you might be able to get rid of gnats for good.
To get rid of gnats you must first find out where they're coming from. Gnats breed in moist areas so try to keep moisture to a minimum. Most likely you'll find their "breeding grounds" in or near a sink, in plants, around fruit, or around rotten foods.
Keep all fruits in the fridge or somewhere where gnats can't get to them. Don't leave dirty dishes in the sink or food sitting in the garbage disposal. Keep sinks clean and the garbage taken out. Don't let rotten food sit in your house. Don't over water plants.
The most obvious way to get rid of gnats is to use a flying insect spray, however, most people aren't too keen on spraying poison all over their kitchens, but it works.
Kill them with a flyswatter. This is one of the most time consuming ways to get rid of gnats because you have to try to track them all down and they seem to go into hiding every time the flyswatter comes out.
Pour a cup of ammonia down the sink drain and let it sit for a couple of hours before using it again.
Gnats love vinegar. In a jar mix half of a cup of vinegar with a tablespoon of Dawn Dish Soap and set it out. The gnats will eat the vinegar and be poisoned by the dish soap.
Create a gnat trap to get rid of gnats. Fill a jar most of the way with vinegar and poke holes in the lid. Gnats will get in, but they won't be able to get out.
If none of the above methods work, you may have to seal up your cupboards, leave for a day or two, and fog your home to get rid of gnats, however having to go this extreme with gnats, is rare.