The lifespan of a fly can vary depending on the species, temperature, food availability, and other factors. However, most flies have a relatively short lifespan, typically lasting between 15 and 50 days. The housefly, for example, has a lifespan of 15 to 30 days, with females laying up to five to six batches of eggs during this time. Fruit flies, on the other hand, live a little longer than house flies, with a lifespan of about 40 to 50 days. The lifespan of a fly can be enhanced by the availability of suitable food, especially sugar. Without food, flies can only survive for about two to three days. Its essential to take proper prevention and fly pest control techniques to avoid an infestation.