Fruit flies, our occasional companions that show up after your confectionary fruit gnawing and at the “aftermath” of your fruit meals, are not only the uninvited guests we should get rid of, the eggs that they lay in your house should also be eliminated as well. Despite their short, 8-day-only life span, they reproduce at an accelerating rate and their eggs hatch within 8 to 10 days. Fruit flies are attracted to rotting or overripe fruits, the remnants of which left in your garbage bin, dank sink and drain can also attract them. To get rid of them, you can make a simple fruit fly trap.
Use a jar or any tall container, put in some sugary stuff such as slices of bruised banana, honey, pieces of rotting fruit, maple syrup, and the like. Next, roll a piece of paper to create a funnel with a tiny opening at the tip and place it in the container with the narrow tip facing down without touching the bait within; remember to tape the paper funnel so that it is firmly in shape, and do not make the tip’s opening big (This is to prevent the fruit flies from getting out of the funnel after they are baited into the container).
Place the trap near fruit bowl, kitchen sink or garbage can. Leave the trap there overnight. Next day, you should see some fruit flies inside the container, they were smart enough to fly in to the container but dumb enough to fly out. Once they are trapped, mix some warm water with dish soap and pour it into the container, the soap will reduce the surface tension of the water and consequently drown them. Wait for a minute or two and then discard the contents (together with the carcasses of the dead flies) of the container outside your house. After that, wash the container with hot water so that you can reuse it to build a new trap. You can put as many of these traps at the fruit fly-infested areas in your house. It is recommended to do the trapping every day for a week or two or until you see no more of these pesky bugs in your house.
To get rid of the eggs, you will need to do proper and regular kitchen cleaning:
(i) Kitchen sink drain should be cleaned because tiny bits of fruit scraps can get stuck in the drain and rot. Simply pour some boiling water with soap dish into the drain to kill the eggs.
(ii) Trash can and compost bin (if you have one) should be cleared and washed.
(iii) Damp sponges and mops should be cleaned, for fruit flies like to breed in these moist stuff too.
(iv) Wash all dishes immediately after meal.
(v) Cover your windows with screens to prevent outside fruit flies from coming in to your kitchen.
Reference: https://www.wikihow.com/Get-Rid-of-Fruit-Flies