Food safety for homemade yogurt works basically the same way as cooking: you are safe as long as you respect the needed time and temperature restrictions.
Yogurt food safety risks
The reason yogurt is safe after staying at room temperature is the same as in all fermented foods. It has a live bacterial culture of benign bacteria, and these fill all available ecological niches, or "spoil" them with products which humans can eat (lactic or acetic acid), so no pathogens can grow. The two risks are
- if you have a large colony of pathogens before you introduce the yogurt culture, the yogurt culture cannot grow and overtake the ecosystem
- if you start with small numbers of both yogurt culture and other (potentially pathogenic) microorganisms, but expose it to an environment that is not well suited to the yogurt culture's needs, it can happen that the other microorganisms multiply quicker and become the ones that overtake the ecosystem.
You can avoid both risks by simply following the proper process.
A nice thing about yogurt is that its fermented nature means it typically spoils by molds instead of bacteria (at least when kept in the fridge), and molds are visible. So, if you have old yogurt (that was safely made) and it's not moldy, you can consider it safe.
The safe process for making yogurt
- Start with safe milk, don't try to "rescue" old milk by yogurting it. Not even if you can't detect any spoilage.
- Pasteurize the milk (which has the double purpose of reducing bacteria and changing the milk protein structure) - if you leave that out, it is not safe
- Let cool down to the proper temperature - for safety, don't let it cool down below that then reheat, continue as soon as it is cooled.
- Add the culture. Here, the safety-relevant thing is to add sufficient amounts of culture - don't try to make 5 liters of yogurt with only a teaspoon of old yogurt. 20-50 g of old yogurt per liter of milk is a good amount, or if you are using industrially packaged culture, it will have the amount stated on the package.
- Incubate at the proper temperature, for the needed time. Here, you can in principle deviate without much trouble safety-wise (although if you do it for too short a time, you'll still have milk instead of yogurt, which will have a shorter storage time in the fridge), but the taste won't be good if you go too short or too long.
- Inspect for signs of improper fermentation.
- Refrigerate the yogurt.
The proper temperature will vary with the culture you choose, the widespread ones are mesophilic (usually bifidobacteria, need 37-40°C, or 98-104°F) and thermophilic (usually lactobacilii, need 43-48°C, or 110-119°F). You have some leeway with temperature, obviously - else mixed cultures wouldn't be able to grow at all - but don't overdo it. If you were to incubate your yogurt at very low temperatures (say 30°C or 86°F) or very high temperatures (e.g. 55°C or 130°F), that would be unsafe.
Do inspect your yogurt when it is done fermenting. It is normal to notice some things which are not usual in storebought yogurt - it might have a skin of either fat or caseine, it might have visibly separated whey, it might have a slightly less smooth texture. But if it is very strange - very liquid, or smelly, or discolored, or has curdled into something closer to quark - then it is not safe to eat.
Hygiene when making yogurt
There is no need to go to extremes, such as sterilizing your equipment. You can still do it if you prefer, but yogurt is still good without it. If you use the same hygiene standard as you do for other cooking and eating utensils, that's sufficient for typical yogurt-making and yogurt-eating habits.
Stronger hygiene can help you in three ways:
- to give you a larger safety margin (not strictly needed, but can make you feel better)
- to give you longer shelf life. I can personally attest that for me, yogurt from the same culture made under the same conditions, resists mold for longer if made in individual containers (sealed airtight before fermentation) than when made in a large container that gets opened and closed to take yogurt out, about 3 weeks vs. 10-12 days.
- to keep your culture pure/usable over more reinnoculations. If you reinnoculate with the same culture, it picks up wild bacteria over time and at some point, it's time to abandon it, because it has lost its taste and texture, or just doesn't work well. If you allow fewer wild bacteria to join, the culture will keep pure for longer. This is only a concern if obtaining fresh culture is difficult or expensive for you, or if you have some very special tasting culture you want to keep really pure for many innoculation cycles.
Instant pot yogurt
I must admit that I have not compared the Instant pot yogurt process specifications against industrial standards, I just trust the manufacturers to have chosen a safe process. The yogurt it makes turns out comparable to making it in a sous vide setup where I can control the temperature and time precisely. So, I think it should be a safe method. An advice that is unrelated to safety: use a separate gasket, else your yogurt will taste like stew.