One way to get rid of gnats is to let the soil around plants that have a gnat infestation to dry out completely. This kills the larvae, and vacuuming removes any remaining adult gnats. Another way to rid a yard of gnats is to set up electric fly exploders.
An additional option to get rid of gnats includes contacting pest removal professionals, such as Orkin and Terminex. Fly swatters and pesticides are also available to homeowners to control their gnat problems. After the problem is under control, homeowners need to keep fruit inside the refrigerator and water plants only when the plants need watering.