Generally, once cut, all pies should be wrapped and refrigerated. But if you’re baking your pie ahead of time, there are a few things to consider. Here’s how long you can store homemade pumpkin pie, how the rules change for store-bought pies, and how to tell if pumpkin pie has gone bad.

How Long Does Pumpkin Pie Last on the Counter?

Whether you’ve baked your pumpkin pie using the filling from a can or from a fresh pumpkin, the rules are the same. Because the pie is made of custard (which includes milk and eggs), pumpkin pie is less forgiving than fruit-filled pies and cannot be left on the counter for too long. Because bacteria grow rapidly at temperatures between 40 F and 140 F, homemade pumpkin pie is only good for two hours sitting out at room temperature. After that, refrigerate your pie. If you left your pie out longer than a few hours, look for any “off” smell or appearance before serving. And, of course, if mold appears, toss that pie.

How Long Does Pumpkin Pie Last in the Fridge?

Freshly baked pumpkin pie will keep for about three to four days in the fridge. You should cover it loosely with aluminum foil or plastic wrap to store it. Because pumpkin pie is delicious cold, you can serve it straight from the fridge (with plenty of whipped cream, if you please). If you prefer, you could take it out of the fridge a couple of hours beforehand, so it comes to room temperature safely.

Store-Bought Pumpkin Pie

Store-bought pumpkin pie is more forgiving thanks to preservatives. Look at the date on the package. If the pumpkin pie was sitting at room temperature in the store, it can continue to be stored on your counter until the sell-by date. In general, store-bought pies last two to four days after their printed date in the refrigerator and about six to nine months in the freezer. Pumpkin pies purchased from bakeries likely do not contain preservatives and, therefore, should be treated like homemade pies.

How to Freeze and Thaw Pumpkin Pie

Frozen homemade pumpkin pie will stay good for up to one month if you want your bake your dessert ahead of Thanksgiving. Here’s how to freeze it: