Preventing diarrhea includes properly preparing food, protecting yourself against infections, and following some proper hygiene habits in your daily life.

Diarrhea can have numerous causes. You may not always be able to tell exactly what brought it on. But there’s plenty you can do to help prevent it from occurring.

Read on to learn how you can prevent diarrhea.

Wash food preparation areas before and after you start making food to avoid food poisoning.

Food poisoning happens when you ingest bacteria-contaminated foods or other foodborne toxins, such as fungi, that disrupt the healthy bacteria in your gut. This can affect your digestion and result in diarrhea.

Be sure to cook food thoroughly, especially meats like beef and chicken and fish, to kill any foodborne bacteria that can also lead to diarrhea.

Avoid using countertops, cutting boards, or other surfaces where you’ve prepared raw meats until they’ve been thoroughly disinfected to avoid spreading bacteria.

Be sure you know what temperature to cook your foods at and to. Use a food thermometer to make sure your foods reach those temperatures before eating them. Avoid eating rare or undercooked meats.

Thaw food in the refrigerator

Don’t thaw out in the open at room temperature. This makes it more likely for bacteria or fungi to grow or spread in it, especially raw meat.

Instead, thaw food in the refrigerator to slow the growth of bacteria before you finally cook it.

Refrigerate leftovers

Don’t leave leftover food unrefrigerated. This can also allow bacteria to get into your digestive tract and cause diarrhea.

Keep leftovers in the refrigerator or freezer until you’re ready to eat them. Be sure to reheat leftovers to 165° F (73.8°C) to kill as many bacteria as possible.

Throw out leftover food after 3–4 days to lower your risk of food poisoning.

Traveler’s diarrhea happens when you eat food or drink water contaminated with bacteria, viruses, or parasites. It is common in areas with different sanitation practices than what you’re used to.

Here are some ways to prevent diarrhea when you’re traveling:

  • Drink bottled water.
  • Don’t drink beverages that use ice made with tap water.
  • Don’t eat food washed with tap water.
  • Don’t brush your teeth with tap water.
  • Try not to change your diet too much.
  • Don’t eat food if you are unsure whether it was cooked or handled properly.
  • Don’t eat meats that look undercooked.

Viral and bacterial infections are the most common causes of diarrhea, especially bacterial gastroenteritis.

To help prevent the spread of viral or bacterial infections, wash your hands before and after you shake hands, share objects or uncooked food, and use the bathroom.

Use soap and warm water for about 20 seconds. Use hand sanitizer with at least 60% alcohol if you’re not able to wash your hands.

If you have a bacterial infection, take the antibiotics a doctor prescribes you. These can help stop the growth of unhealthy bacteria in your gut and reduce symptoms like diarrhea.

Rotavirus is a type of virus that’s often found in stool or in contaminated food that’s been touched by someone with the virus, even if they don’t have an active infection.

Rotavirus happens most commonly to children under 5 years old. Children who are vaccinated against rotavirus are much less likely to get an infection and have diarrhea as a result.

Diarrhea is also known to be a symptom of COVID-19. Vaccines for COVID-19 can help prevent diarrhea and other complications of this disease.

Children can get diarrhea for different reasons than adults. Here are some tips to help prevent diarrhea in children:

  • Make sure your child drinks plenty of water, especially if they already have diarrhea, as diarrhea can dehydrate them.
  • Have your child tested for food allergies or sensitivities at a young age to help them avoid foods that might cause diarrhea.
  • Check the ingredients of any food you give to your child to make sure they’re not sensitive to them.
  • Limit how much milk or cheese you give to your child each day if these foods seem to bring on diarrhea or stomach aches.
  • Avoid having your child eat too much sugar or processed foods.

Bismuth subsalicylate (Pepto-Bismol) is a popular preventive medication for diarrhea. Additionally, loperamide (Imodium) is often used as a general treatment until the cause of diarrhea is identified. Don’t give either to children unless they’re prescribed by their doctor.

Here are some general tips to help prevent diarrhea:

  • Drink 9–13 cups of water every day. Adjust your water intake based on your level of physical activity.
  • Wash your hands with soap and water regularly for at least 20 seconds.
  • Don’t share towels, food utensils, or other items with someone who has diarrhea.
  • Practice proper personal hygiene habits, such as bathing or showering regularly to keep unhealthy bacteria from growing on your body.
  • Take probiotics to help promote healthy gut bacteria.
  • Stay away from foods that upset your digestive tract, especially high fat or greasy foods.

Diarrhea is common, but it can be prevented through diet and lifestyle changes. There are also over-the-counter and prescription medications you can take to help manage severe or long-term cases of diarrhea.

Seek medical attention if diarrhea is severe or lasts more than 24 hours for infants and older adults or 2–3 days for healthy adults.