You’ve been storing bags of rice, flour or pet food in the pantry without giving it a second thought. But then one day a tiny moth flies out of your pantry. Bad news: Your home is infested.

The common pantry moth won’t hurt you, but there’s an ick factor to finding out your food is infested, and it can be tricky to get rid of the moths.

Unfortunately, it’s pretty easy for these moths, known as Indian meal moths, to hitch a ride into your house. The problem starts when a female moth lays as many as 300 eggs in grain or other food, often sneaking in through a tear in the bag.

The eggs are so tiny that they’re almost impossible to see, according to The Pennsylvania State University’s College of Agricultural Sciences. And the newly hatched caterpillars are almost invisible too.

The caterpillars eat and grow larger. Eventually, they spin a cocoon out of whitish webbing that looks like a spider web. After a few weeks, an adult moth comes out.

Related: How to Get Rid of Bedbugs

Pantry moth (Photo: jupeart/Shutterstock)

Pantry moths will eat just about any grain product, along with some other foods. They commonly munch on breadcrumbs, cereal, flour, nuts and whole grains, says Jeffrey Hahn, an entomologist with the University of Minnesota Extension. They’ll even eat chocolate, dried fruit and spices.

“There’s almost nothing they don’t get into,” Hahn says.

But if you get pantry moths, there’s no need to buy a can of pesticide spray. In fact, the best ways to get rid of pantry moths are natural, safe and simple. 

Here’s how to take control of a pantry moth infestation in five steps.

Related: Tips for Greener House Cleaning

1. Go right to the source. Attack the problem by hunting down the source of the infestation — the product in which the moths are living, feeding and breeding. The source could be an open bag of flour, a box of rice or even a bag of dry dog food, Hahn says. “If you see whitish caterpillars — larvae — and webbing, you’ve hit the jackpot.” Throw out the infested product in an outdoor trash can. Then check your pantry again because there might be more than one source, Hahn says.

2. Freeze the moths out. Take an extra step that will kill any eggs, larvae or moths hiding in your food: Put your grains, flour, spices and similar products in your freezer for about a week, Hahn suggests.

3. Clean up crumbs. Clean your kitchen from top to bottom, making sure to wipe up any spilled flour or crumbs on your pantry shelves. Pantry moths can feed on little bits of spilled food.

4. Seal up your stuff. Store your whole grains, flour products, nuts, seeds, spices and even your dog or cat food in glass jars or sturdy plastic containers with lids that seal tightly. Products your family finishes quickly, like breakfast cereal, are probably fine sitting on shelves in sealed containers. But you might want to stash flour and other items that take a while to use up in the fridge, Hahn recommends.

5. Grab the fly swatter. Even after you’ve taken all the steps to tackle the infestation, you might see a moth or two flying around your kitchen over the next couple of weeks. That’s because caterpillars can spend several weeks in their cocoons before they hatch and start flitting around your home. Swat the moths if you can. “Every one you kill means one less can go back and lay eggs,” Hahn says.

If you still see moths after a month, you probably need to go back to step one. “You know there’s still an infested source somewhere,” Hahn says.

Related: 6 Cleaning Mistakes You’re Probably Making

Allie Johnson is an award-winning freelance consumer writer with a degree in magazine journalism. She lives in Georgia with her husband and two dogs.