I'm not sure. One thing to do is make sure there aren't any food stuffs out where they can get to them. Very important. And if you don't have screen doors get them and keep them shut except when people are coming and going.
The best way is to swat them, indoors and outdoors. You need to break the breeding cycle. Don't leave pet food outside for more than 20 min. Hose off patios, decks, tables, anything food may have come into contact with regularly.
try these tips: https://www.craftylittlegnome.com/flies-house-suddenly/
If you want to get rid of fruit flies try this https://www.homeroad.net/2015/10/a-fruit-fly-trap-that-works.html