They are breeding in something wet and fermenting, usually a drain, a bin or a forgotten piece of fruit. Find that and the flies stop within days.
- Look for the source. Overripe fruit, the bottom of the bin, a recycling box with unrinsed bottles, a sink overflow, a drip tray under the fridge, a mop bucket.
- Clean the drains. Pour boiling water then a drain cleaner or soda crystals down the sink and the overflow, which is often the actual breeding site.
- Set a trap: a glass of cider vinegar with a drop of washing-up liquid, covered with cling film with a few holes in it.
- Refrigerate fruit and rinse recycling until the problem is gone.
Spraying insecticide around a kitchen does not address a breeding site and puts chemicals near food. Fruit flies complete a generation in about a week, so removing the source is faster than killing the adults.
Fruit flies are attracted to acetic acid and ethanol from fermentation, which is exactly why cider vinegar works as a lure and why the washing-up liquid matters: it breaks the surface tension so they sink rather than standing on it.
Household chemicals can be dangerous in combination. Never mix them, keep the room ventilated, and test anything on a hidden patch first. Full disclaimer.