Coughing is a natural reflex. It’s your body’s way of clearing your airways of irritants (such as mucus, allergens, or smoke) and preventing infection.

Coughs are often categorized as dry or productive. A productive cough brings up sputum (mucus, phlegm, and other matter) from the lungs.

Mucus forms a protective coating to keep irritants and germs away from the delicate and sensitive tissues of your airways. Our nose and sinuses produce an average of about a liter of mucus every day.

The airways of the throat and lungs also produce mucus. And the body makes even more mucus when we’re reacting to an allergy or have a cold or infection.

If you’re coughing up mucus, it’s an indication that you have an irritation or possible infection in your respiratory tract.

Solid white mucus

When you cough up thick, solid white mucus, it might be a signal that you have a bacterial infection in your airways. This type of an infection could require prescription antibiotics from your doctor.

Foamy white mucus

Mucus that contains bubbles and is foamy is commonly referred to as frothy sputum. Frothy sputum can sometimes be a sign of:

If you’re coughing up frothy sputum, review this and other symptoms with your doctor.

Looking at the color of the mucus you’re coughing up isn’t an effective diagnostic tool on its own. The most effective way of identifying bacterial infections is by testing a sample of the sputum in a laboratory.

But mucus color can play a role in determining what’s going on in your respiratory system.

A 2012 study published in the European Respiratory Journal showed the following results from sputum samples that were positive for bacterial growth when cultured:

  • Clear phlegm tested positive for bacteria capable of causing infection in 18 out of every 100 samples.
  • Yellow sputum contained bacteria capable of causing infection in 46 out of every 100 samples.
  • Green sputum contained bacteria capable of causing infection in 59 out of every 100 samples.

Clear mucus

If you’re coughing up light-colored or clear mucus, it might indicate that you’re dealing with allergies or that you have a minor infection in your respiratory tract.

Yellow or green mucus

If you’re coughing up yellow or green mucus, it might indicate that you have a respiratory infection.

Your mucus changes color because of defensive enzymes that your immune system is releasing. A green tint comes from an iron-containing enzyme, for example.

There are a number of steps you can take to clear mucus, including the following:

  • Keep yourself hydrated by drinking plenty of fluids — especially water. If you become dehydrated, your mucus can get thicker, which, in turn, may make your cough worse.
  • Rest and conserve your energy for fighting off the infection that could be the trigger for your mucus production.
  • Consider over-the-counter medications. Examples include:
    • expectorants such as guaifenesin (Mucinex)
    • decongestants such as oxymetazoline nasal spray (Afrin, Sudafed OM)
    • pseudoephedrine (Contac 12-Hour, Dimetapp Decongestant)
    • antitussives such as dextromethorphan (Triaminic Cold and Cough, Robitussin Cough).

Consult with your doctor — especially if your symptoms become worse or don’t go away after 9 days.

Producing mucus is one of your body’s methods of protecting your respiratory system. When there is an accumulation of mucus, you tend to cough it up.

Although the cause is often a response to a viral infection or an allergy, coughing up mucus could be an indication of a bacterial infection.

There are a number of simple ways to care for yourself if you’re coughing up mucus. But if the symptoms continue to worsen or stick around for 10 days or more, visit your doctor.