Pneumonia is a bacterial, viral, or fungal infection in your lungs
Pneumonia is an infection. It happens when germs — bacteria, viruses, or fungi — get into the air sacs of your lungs (called alveoli) and multiply. Your immune system responds to fight the infection, which causes inflammation and fills those air sacs with fluid or pus. That's why you cough, struggle to breathe, and feel sick.
The infection can start in different ways. You might breathe in germs from the air when someone nearby coughs or sneezes. You might aspirate — accidentally inhale saliva or food that carries bacteria into your lungs instead of going down your esophagus. Or germs already in your bloodstream can travel to your lungs. Once the infection takes hold, your body has to work hard to clear it.
Not all pneumonia is the same. Bacterial pneumonia tends to come on suddenly and cause high fever and thick, colored sputum. Viral pneumonia usually develops more gradually and causes a dry cough. Fungal pneumonia is less common and usually only happens if your immune system is already weakened. The type matters because treatment depends on what's causing it.
Key Takeaways
- Pneumonia is caused by bacteria, viruses, or fungi that infect the air sacs in your lungs and trigger inflammation.
- You can catch pneumonia by breathing in germs from another person, by aspirating contaminated material, or through germs already in your bloodstream.
- Bacterial pneumonia usually starts suddenly with high fever; viral pneumonia develops more slowly and often with a dry cough.
- Your doctor can determine what type of infection you have through a chest X-ray and sometimes a sputum culture or blood test.
How the infection spreads through your lungs
When you breathe in bacteria or viruses, they land in your airways and begin to multiply. Your lungs have natural defenses — mucus, cilia (tiny hair-like structures that sweep debris out), and white blood cells — that normally catch and clear these germs before they cause trouble. But if you're already sick, tired, or your immune system is weak, those defenses can fail.
Once germs reach the alveoli, they trigger an inflammatory response. Your body sends white blood cells to fight the infection, but this also causes swelling and fluid buildup. The air sacs fill with pus or fluid instead of air, which means less oxygen gets into your bloodstream. That's why pneumonia makes you short of breath and causes that heavy, tight feeling in your chest.
The infection can stay localized to one part of your lung, or it can spread to both lungs. It can also move into your bloodstream, which is more serious. This is why doctors listen to your lungs with a stethoscope and often order a chest X-ray — they need to see how much of your lung is affected and whether the infection is spreading.
Bacterial, viral, and fungal pneumonia are different infections
Bacterial pneumonia is caused by bacteria like Streptococcus pneumoniae or Haemophilus influenzae. It typically comes on fast — you might feel fine one day and very sick the next. You'll usually have a high fever (often above 102°F), chills, and a cough that brings up thick, greenish or rust-colored sputum. Bacterial pneumonia responds to antibiotics, but you need the right one for the specific bacteria causing your infection.
Viral pneumonia is caused by viruses like influenza, respiratory syncytial virus (RSV), or coronaviruses. It usually develops more gradually over several days. Your fever is often lower, and your cough is usually dry at first. Viral pneumonia doesn't respond to antibiotics — your body has to fight it off on its own, though your doctor may prescribe antivirals for certain viruses like flu. Viral pneumonia can sometimes lead to bacterial pneumonia as a secondary infection.
Fungal pneumonia is rare in healthy people. It's more common in people with weakened immune systems — those with HIV/AIDS, people on immunosuppressant medications, or those who have had organ transplants. Fungal pneumonia develops slowly and can be harder to diagnose because the symptoms are less dramatic. Treatment requires antifungal medications, which work differently than antibiotics.
Why your doctor needs to identify which type of infection you have
Knowing whether your pneumonia is bacterial, viral, or fungal changes how your doctor treats it. If you have bacterial pneumonia and your doctor prescribes antibiotics, the right antibiotic can clear the infection in a week or two. But if you have viral pneumonia and take antibiotics, they won't help — antibiotics don't kill viruses. Worse, unnecessary antibiotics contribute to antibiotic resistance, which makes infections harder to treat overall.
Your doctor usually starts by listening to your lungs and asking about your symptoms. A chest X-ray shows whether you have pneumonia and how much of your lung is affected. If your doctor suspects bacterial pneumonia, they may order a sputum culture — you cough into a cup, and the lab grows whatever bacteria are present to identify the exact type. Blood tests can also show signs of bacterial infection.
Sometimes your doctor will start antibiotics before the culture results come back, especially if you're very sick. This is called empiric treatment — they use antibiotics that work against the most common bacteria. Once the culture identifies the specific bacteria, your doctor may switch to a more targeted antibiotic. This approach balances the need to treat you quickly with the need to use the right medication.
Risk factors that make pneumonia infection more likely
Some people are more likely to develop pneumonia than others. Age matters: very young children and adults over 65 have weaker immune responses. Chronic lung disease like COPD or asthma makes your lungs more vulnerable. Smoking damages the cilia that normally clear germs, so smokers get pneumonia more often and more severely.
A weakened immune system from HIV, cancer treatment, or immunosuppressant medications increases your risk. Recent surgery or hospitalization puts you at higher risk because you may have been exposed to hospital bacteria and your body is already stressed. Alcohol use disorder, heart disease, and diabetes also increase risk. If you've recently had the flu, you're at higher risk for pneumonia because the flu damages your airways and makes them easier for bacteria to invade.
Aspiration pneumonia is a specific type of infection that happens when you accidentally inhale food, saliva, or stomach contents into your lungs instead of swallowing normally. This is more common in people with swallowing problems, those who are sedated or unconscious, or people with neurological conditions like stroke or Parkinson's disease. The bacteria that live in your mouth and throat can then cause infection in your lungs.
When pneumonia infection becomes serious
Most people recover from pneumonia with treatment, but the infection can become life-threatening. Sepsis happens when the infection spreads into your bloodstream and your body's response to the infection causes organ damage. Signs include confusion, very low blood pressure, rapid heart rate, and difficulty breathing. Sepsis requires immediate hospital care.
Respiratory failure occurs when your lungs can't get enough oxygen into your blood or remove enough carbon dioxide. If this happens, you may need a ventilator to help you breathe. Pleural effusion is when fluid builds up around your lungs, which can make breathing harder. Empyema is when that fluid becomes infected — it's a serious complication that may need drainage.
Pneumonia can also trigger or worsen other conditions. If you have heart disease, pneumonia can strain your heart. If you have COPD, pneumonia can cause a flare-up. This is why people with chronic conditions are urged to get pneumonia vaccines — preventing the infection is easier than treating complications.
Prevention through vaccines and good hygiene
Vaccines can prevent some types of pneumonia infection. The pneumococcal vaccine (Pneumovax or Prevnar) protects against Streptococcus pneumoniae, which causes about one-third of bacterial pneumonia cases. The flu vaccine reduces your risk of influenza, which means you're less likely to develop pneumonia as a complication. These vaccines don't may provide you won't get pneumonia, but they significantly reduce your risk and usually make the infection milder if you do get it.
Basic hygiene reduces transmission. Wash your hands regularly, especially before eating and after being around sick people. Cover your cough and sneeze with your elbow or a tissue, not your hands. If you're sick, stay home to avoid spreading germs to others. If someone in your household has pneumonia, keep their dishes, towels, and bedding separate and wash them in hot water.
If you smoke, quitting is one of the most important things you can do to reduce your pneumonia risk. Smoking damages your lungs' ability to clear germs. If you have a chronic lung condition, work with your doctor on a management plan — controlling asthma or COPD makes your lungs more resilient. If you're hospitalized, follow infection control practices and ask your healthcare team about pneumonia prevention.
Frequently Asked Questions
Can you catch pneumonia from someone else?
Yes, if the pneumonia is caused by bacteria or viruses that spread through the air. When someone with pneumonia coughs or sneezes, they release droplets containing germs. If you breathe those in, you can develop pneumonia. Fungal pneumonia is not contagious — you can't catch it from another person.
Is all pneumonia treated with antibiotics?
No. Antibiotics only work against bacterial pneumonia. Viral pneumonia must run its course while your immune system fights it, though antivirals may help with certain viruses like influenza. Fungal pneumonia requires antifungal medications. Your doctor will determine the type before deciding on treatment.
How long does a pneumonia infection last?
Bacterial pneumonia usually improves within a few days of starting the right antibiotic, though you may feel tired for weeks. Viral pneumonia typically lasts one to three weeks. Fungal pneumonia can take much longer to clear. Even after you feel better, it can take months for your lungs to fully heal and your energy to return.
Can pneumonia come back after you've had it once?
Yes. Having pneumonia once doesn't make you immune. You can catch a different strain of bacteria or virus, or the same one again if you're exposed. People with chronic lung disease or weakened immune systems are at higher risk for recurrent pneumonia. Vaccines and good hygiene reduce the risk of getting it again.
What's the difference between pneumonia and bronchitis?
Bronchitis is inflammation of the airways (bronchi) that carry air to your lungs. Pneumonia is infection in the air sacs themselves. Bronchitis usually causes a cough but doesn't show up on a chest X-ray. Pneumonia shows up as infiltrates on X-ray and causes more severe breathing problems. Bronchitis can sometimes develop into pneumonia.