Pneumonia is a lung infection caused by bacteria, viruses, or fungi. Some of these germs do spread from person to person, so you may be contagious if you have certain types of pneumonia. However, not everyone will develop pneumonia when exposed to the same germs.

There are many viruses that can cause pneumonia, and viruses can pass from person to person easily. For example, the influenza virus can survive on surfaces, making it even more contagious.

Bacterial pneumonia can spread from person to person as well.

Fungal pneumonia passes from the environment to a person, but it’s not contagious from person to person.

Most pneumonia is caused by either bacterial or viral organisms. These can spread in a number of ways, including:

  • coughs or sneezes that aren’t covered
  • sharing cups or eating utensils
  • touching a tissue or other item after someone with bacterial or viral pneumonia has used it
  • not washing your hands regularly, especially after blowing your nose, coughing, or sneezing

Not everyone who is exposed to these bacteria or viruses will develop pneumonia. People who are at high risk of developing pneumonia include:

You should call the doctor if you think an illness may be pneumonia and you are in a high-risk category. You should also contact a medical professional if:

  • you have chest pain
  • you have an ongoing cough lasting more than a week
  • your symptoms are getting worse
  • you have difficulty breathing or shortness of breath
  • you have a fever over 100.4˚F (38˚C) for more than 3 days

Keep reading: 7 ways to flu-proof your home »

Bacterial pneumonia

You may be contagious if you have a form of bacterial pneumonia, including:

  • Methicillin resistant Staphylococcus aureus (MRSA) pneumonia
  • Streptococcal pneumonia
  • walking pneumonia
  • chlamydial pneumonia

Your doctor will prescribe antibiotics to treat bacterial pneumonia. You should be no longer contagious a day or two after starting antibiotics and once your fever resolves, if you had one.

Viral pneumonia

You can also be contagious if you have viral pneumonia. The same viruses that cause colds and flu can cause viral pneumonia. Other viruses that attack the respiratory system can be causes as well.

Viral pneumonia is contagious until you are feeling better and have been free of fever for several days.

Noncontagious types of pneumonia

It’s possible to have pneumonia that can’t spread to other people. Fungal pneumonia and aspiration pneumonia are examples of pneumonias that aren’t usually contagious.

Fungal pneumonia typically occurs in people that have a weakened immune system or other serious health issues. The fungi that causes this type of pneumonia is usually found in soil. You’re not generally contagious if you have fungal pneumonia. That’s because it’s caused by inhaled fungi from your environment, not spread from person to person.

Aspiration pneumonia is not contagious because it is caused by inhaling food or liquid into your lungs. This can happen in people who have had a stroke or have other neurologic conditions.

Here are some steps that can help reduce your exposure to bacteria or viruses that can cause pneumonia:

Read more: When to stay home sick »

Vaccines are an important and effective way to prevent both viral and bacterial infections in children and adults. Pneumonia is a common complication with many of these infections.

Helpful vaccines for children:

  • Haemophilus influenzae type b
  • Prevnar (for Streptococcal pneumonia)
  • DTaP or Tdap (tetanus, diphtheria, and pertussis)
  • flu
  • MMR (measles, mumps, and rubella)
  • meningitis

Helpful vaccines for adults:

  • Pneumovax (for Streptococcal pneumonia)
  • varicella (chicken pox)
  • flu
  • Tdap
  • shingles
  • meningitis

Talk to your doctor about which vaccines are right for you and your family.