Vinegar, sugar water and wine are natural methods to kill indoor gnats that are drawn to fruit. For gnats on plants, removing the top inch of soil or covering it with sliced potato prevents nesting. Pesticides are another option.
Gnats, also known as fruit flies, breed on moist organic products. Rotting fruit and watery soils are optimum nests for gnats. Sweet fermented liquids left in shallow bowls draw gnats away from organic products. The gnats drown when trapped through poked plastic covering the bowls.
Replacing the first inch of infested soil is an option for overly watered plants. Attracting gnat larvae to feed on thinly sliced potatoes also reduces risks for infestation in topsoil. Pesticides suitable for household plants kill swarming gnats.