Pneumonia starts when germs get into your lungs and your body cannot clear them

Pneumonia happens when bacteria, viruses, or fungi enter the air sacs in your lungs (called alveoli) and multiply there. Your lungs fill with fluid or pus instead of air, making it harder for oxygen to reach your bloodstream. You do not catch pneumonia the way you catch a cold — it is not just about exposure to a germ. Whether you get pneumonia depends on which germ it is, how much of it you breathe in, and how well your immune system can fight it back.

Most people breathe in germs every day without getting sick. Your lungs have defenses: tiny hairs called cilia that sweep mucus out, white blood cells that kill invaders, and a cough reflex that clears your airway. Pneumonia develops when these defenses break down or when a particularly aggressive germ overwhelms them.

Key Takeaways

  • Bacterial pneumonia, viral pneumonia, and fungal pneumonia each develop differently and require different treatment approaches.
  • Respiratory viruses like influenza and COVID-19 can lead to pneumonia, especially if they damage the lining of your lungs.
  • Certain conditions — including chronic lung disease, heart disease, diabetes, and a weakened immune system — make pneumonia much more likely.
  • Aspiration pneumonia occurs when food, liquid, or stomach contents accidentally enter your lungs instead of going down your esophagus.
  • Age, smoking, recent surgery, and prolonged bed rest all increase your risk of developing pneumonia after a respiratory infection.

Bacterial pneumonia and how it spreads

Streptococcus pneumoniae is the most common bacterial cause of pneumonia in adults. You can breathe it in from respiratory droplets when an infected person coughs or sneezes, or you may already carry it in your nose and throat without being sick — then it travels down into your lungs when your defenses are low. Other bacteria that cause pneumonia include Haemophilus influenzae, Legionella (which grows in warm water systems), and Mycoplasma (which causes "walking pneumonia" because symptoms are often mild).

Bacterial pneumonia typically develops after your immune system has already been weakened by something else. A recent cold or flu, a chronic lung condition like COPD, or even just being bedridden for several days can lower your defenses enough for bacteria to take hold. Once bacteria settle in the air sacs, they multiply rapidly, and your immune system responds by sending white blood cells to fight them — this causes inflammation, fluid buildup, and the symptoms you feel.

Viral pneumonia and respiratory infections

Viruses cause pneumonia differently than bacteria do. When you breathe in a respiratory virus like influenza, respiratory syncytial virus (RSV), or COVID-19, it infects the cells lining your airways and air sacs. The virus damages these cells, causing inflammation and fluid to leak into the air sacs. This fluid buildup is what creates pneumonia — your lungs fill with fluid instead of staying clear for oxygen exchange.

Viral pneumonia is often less severe than bacterial pneumonia, but it can be serious, especially in older adults or people with chronic conditions. Some people recover on their own as their immune system clears the virus. Others develop secondary bacterial pneumonia — meaning a bacterial infection takes hold on top of the viral damage — which is why people sometimes get sicker a week or two after their initial cold or flu symptoms started to improve.

Fungal pneumonia and environmental exposure

Fungal pneumonia is less common than bacterial or viral pneumonia, but it happens when you breathe in fungal spores from the environment. Histoplasmosis comes from soil contaminated with bird or bat droppings, particularly in river valleys in the central United States. Coccidioidomycosis (valley fever) comes from dust in the southwestern desert. Blastomycosis grows in moist soil and wood.

Most people who breathe in these spores do not develop pneumonia — their immune system clears the spores without symptoms. Fungal pneumonia typically develops in people whose immune systems are significantly weakened, such as those with untreated HIV, those taking immunosuppressant medications, or those recovering from a major illness. If you have a weakened immune system and live in or travel to an area where these fungi are present, your doctor may discuss prevention strategies with you.

Aspiration pneumonia: when food or liquid enters the lungs

Aspiration pneumonia develops when food, liquid, stomach contents, or saliva accidentally enters your lungs instead of going down your esophagus to your stomach. This can happen if you have difficulty swallowing (from a stroke, neurological condition, or advanced age), if you are sedated or unconscious, or if you vomit while lying down. The material that enters your lungs can carry bacteria from your mouth and stomach, or it can cause chemical irritation that leads to infection.

Aspiration pneumonia is common in people who have had a stroke, those with Parkinson's disease or other neurological conditions affecting swallowing, and those who are bedridden or sedated in hospitals. It can also happen to anyone during a single incident — for example, if you choke while eating or if you inhale vomit. If you or someone you care for has difficulty swallowing, your doctor can recommend strategies to reduce aspiration risk, such as eating thickened foods or adjusting body position during meals.

Conditions that increase your pneumonia risk

Certain medical conditions make your lungs more vulnerable to pneumonia. Chronic obstructive pulmonary disease (COPD), asthma, and other chronic lung diseases damage your airways and make it harder to clear mucus and germs. Heart disease reduces blood flow to your lungs and weakens your overall immune response. Diabetes impairs your white blood cells' ability to fight infection. Kidney disease, liver disease, and cancer all compromise immune function.

A weakened immune system — whether from HIV, medications that suppress immunity, or recent chemotherapy — is one of the strongest risk factors for pneumonia. People with these conditions are not only more likely to develop pneumonia, but also more likely to develop severe pneumonia or pneumonia from unusual germs that would not typically cause disease in a healthy person. If you have any of these conditions, your doctor may recommend pneumonia vaccines and may monitor you more closely if you develop respiratory symptoms.

Lifestyle and situational factors that raise your risk

Smoking damages the cilia in your lungs — those tiny hairs that sweep out mucus and germs — so smokers are significantly more likely to develop pneumonia. Alcohol use disorder impairs immune function and increases aspiration risk. Recent surgery, especially chest or abdominal surgery, increases pneumonia risk because pain limits how deeply you breathe and cough, allowing secretions to pool in your lungs.

Prolonged bed rest, whether from hospitalization, injury, or illness, allows fluid and secretions to accumulate in your lungs. Being in a hospital or nursing home also increases risk because you are exposed to bacteria that are resistant to many antibiotics. Age itself is a risk factor — pneumonia is more common and more severe in adults over 65. If you are facing surgery or a period of bed rest, your doctor may discuss ways to reduce pneumonia risk, such as breathing exercises or early mobilization.

How your immune system responds to pneumonia-causing germs

When a germ enters your lungs, your immune system recognizes it as foreign and launches a response. White blood cells rush to the infected area, and your body releases chemicals that cause inflammation. This inflammation is actually your immune system fighting back — but it also causes the symptoms you feel: fever, cough, chest pain, and difficulty breathing. The inflammation causes the air sacs to fill with fluid or pus, which is what shows up on a chest X-ray.

In most cases, your immune system eventually wins and clears the infection. But if the germ is particularly aggressive, if you have a weakened immune system, or if you have other health conditions that complicate recovery, the infection can spread or worsen. This is why people with pneumonia need monitoring — your doctor is watching to see whether your immune system is gaining control or whether the infection is progressing and needs treatment.

Frequently Asked Questions

Can you get pneumonia from being cold or wet?

Cold weather and wet conditions do not directly cause pneumonia, but they can increase your risk indirectly. Cold air can irritate your airways, and people spend more time indoors in close contact during winter, which increases exposure to respiratory viruses. If a virus damages your lungs, pneumonia can develop. Being wet and cold may also lower your immune response slightly, but the germ itself is what causes pneumonia.

Is pneumonia contagious?

It depends on the cause. If your pneumonia is caused by a virus like influenza or COVID-19, you can spread the virus to others through respiratory droplets, and they may develop pneumonia or another respiratory illness. Bacterial pneumonia is generally not contagious — you cannot catch the bacteria from someone with pneumonia. However, the respiratory virus that led to their bacterial pneumonia might be contagious.

Can pneumonia develop without a recent cold or flu?

Yes. While pneumonia often follows a respiratory infection, it can also develop on its own, especially in people with weakened immune systems, chronic lung disease, or heart disease. Aspiration pneumonia can happen without any preceding illness. If you develop pneumonia symptoms without a recent cold, tell your doctor — it may indicate an underlying condition that needs attention.

Why do some people get pneumonia after surgery?

Surgery increases pneumonia risk for several reasons: anesthesia affects your cough reflex, pain limits how deeply you breathe, you may be immobilized in bed, and your immune system is focused on healing the surgical wound. Secretions can pool in your lungs, creating an environment where bacteria can grow. Your surgical team typically gives you breathing exercises and encourages early movement to reduce this risk.

Can you get pneumonia twice?

Yes. Having pneumonia once does not make you immune to future pneumonia. You can get pneumonia from different germs, or from the same germ if your immune system has weakened since your first infection. People with chronic lung disease or weakened immune systems are at higher risk for recurrent pneumonia. If you develop pneumonia more than once, your doctor may investigate whether an underlying condition is making you vulnerable.