Maggots are fly larvae, usually of the common housefly and also the bluebottle. Flies are attracted to food and other rubbish; they lay their eggs on the rubbish; later the eggs hatch into maggots.
How do maggots appear out of nowhere?
Maggots don't just show up out of nowhere; they show up for a reason. Flies become attracted to some rotting material or spoiled food in your home and use that as a breeding ground to lay their eggs which hatch to become maggots.
How do I get rid of maggots?
Natalie adds: "Identify what the maggots are feeding on, clean/clear this up (along with the maggots themselves) and dispose of it in a sealed bag in an external bin. By removing the food source of the maggot, you will deprive any remaining maggots and they will not be able to grow or survive.