When you’re coughing up phlegm or you have mucus running down your nose, you probably don’t pay much attention to it unless you notice a startling change in color. Black or dark phlegm or mucus can be particularly distressing, and for good reason. It can often signal a serious disease or exposure to unhealthy pollutants.

The mere presence of mucus, however, is not a sign of disease and shouldn’t pose medical concerns. Mucus serves an important purpose. It protects and lubricates your nasal passages and other cavities in the body, and it can help prevent infection and help clean out your airway passages.

Phlegm is like mucus, except that it’s generated in the lungs. Phlegm can be a symptom of disease, and it can be caused by bacteria, viruses, and other unwanted cells. It can also occur with serious lung conditions.

When you’re sick, mucus is what you wipe from your nose and phlegm is what you cough up from your lungs. And once phlegm is coughed out of your mouth, it’s called sputum.

If you ever cough up black phlegm, see a doctor as soon as possible. The discoloration may be temporary, caused by exposure to smoke or dirt in the air, or it could be due to a respiratory infection. Black phlegm could also be caused by a more serious condition, such as lung cancer. A prompt medical evaluation is important.

When you see a doctor about black phlegm or mucus, you should think about whether any of the following things apply to you:

Irritants

Everything you inhale finds a home somewhere. Oxygen, for example, makes its way first into your lungs and then into your bloodstream, where it keeps your organs and muscles healthy. But not everything you breathe in can be put to use in a healthy way.

Pollutants

Breathing in air pollutants can cause mucus to turn black. Particles of dirt or industrial chemicals can settle in the airways, darkening the color of mucus and phlegm. When you travel to a place with heavy pollution and poor air quality, you may see changes in your mucus. Once your exposure to airborne pollutants ends, your phlegm should soon return to its normal color.

Smoking

The chemicals in cigarettes and other smoking implements lodge in your airways, turning mucus and phlegm dark. Smoking also causes phlegm to thicken in your lungs, triggering more coughing. One reason for this buildup is that smoking can damage or destroy the cleaning mechanism of the lungs — the hairlike cilia that line the lungs. This allows phlegm to clog your airways. Smoking is, of course, also a risk factor for lung cancer, a wide variety of other cancers, heart disease, and most other respiratory problems.

Coal mining

The clinical term for what has long been known as “black lung disease” is pneumoconiosis. It’s a condition that’s most often associated with coal miners. However, black mucus and phlegm can also be caused by exposure to other workplace irritants, such as asbestos and silica.

Fire

The smoke from large fires can deposit soot in your airways, turning your mucus and phlegm black. Wearing a special mask over your nose and mouth when exposed to a large fire or polluted air can help prevent irritants from settling in your airways.

Infections

Diseases that affect your respiratory system can cause many changes in the color and thickness of your mucus. These changes are important symptoms for your doctor to review, but they’re often accompanied by other signs of illness.

Fungal infection

For people who aren’t smokers or who aren’t exposed to harmful pollutants, black mucus is often associated with a serious fungal infection that settles in the lungs. You may be at greater risk of fungal infection if you have a compromised immune system. Going through cancer treatment, for example, or having an autoimmune disorder such as rheumatoid arthritis can weaken your immune system, making you more susceptible to infections.

The types of fungus that can be breathed in and cause an infection are often found in hot climates, such as the desert Southwest or the tropics. The airway irritation caused by an infection may even cause some bleeding, which can turn mucus a reddish brown or black.

Tuberculosis

Tuberculosis, or TB, is a highly contagious bacterial infection. It strikes most often when a person’s immune system is weak. In addition to dark phlegm, other signs of TB include a nagging cough that lasts for weeks, chest pain, weight loss, night sweats, and coughing up blood.

Pneumonia

Pneumonia is an infection of the air sacs in the lungs, and it often leads to fluid buildup in one or both lungs. Pneumonia is a potentially fatal condition. It can be a difficult disease to treat because it may be caused by a wide range of bacteria, viruses, and other organisms. In addition to dark mucus, other signs of pneumonia include chest pain, shortness of breath, coughing, fever, and fatigue.

Other causes

Black mucus or phlegm has many other possible causes. That’s why it’s important to pay close attention to other symptoms.

Heart valve disease

Blood travels from the heart, through the lungs (where it exchanges carbon dioxide for oxygen), and then back to the heart to be pumped out to the rest of the body. When defective or diseased heart valves don’t allow easy passage of blood in and out of the heart, it can back up into the lungs.

In heart valve disease, this backed up fluid can build up in the lungs, causing congestive heart failure. This can create frothy or blood-streaked sputum, causing phlegm to become pink, red, rust-colored, brown, or black.

Blood thinners

Anticoagulants and antiplatelet medications are designed to reduce the risk of developing blood clots that could potentially block an artery, leading to conditions such as heart attack or stroke. Unfortunately, these blood-thinning medications can raise the risk of internal bleeding.

Coughing up blood or dark phlegm is a sign of a bleeding event and a possible signal that your medication regimen needs adjusting.

Autoimmune disease

Some autoimmune or inflammatory diseases, such as sarcoidosis, directly affect the lungs and cause black or brown phlegm to develop. This is related to bleeding within the respiratory tract. Sarcoidosis may also affect the skin, eyes, sinuses, kidneys, and other organs. Other autoimmune diseases, such as lupus and rheumatoid arthritis, can affect the lungs and other parts of the body differently.

Lung cancer

Lung cancer is diagnosed when lung cancer cells are discovered in the lungs, lymph nodes, or other organs. Coughing up blood and having black phlegm are signs that a thorough lung exam is needed to either rule out or confirm lung cancer.

In addition to black, mucus can turn any of several other colors due to illness or other factors. Each color can indicate a particular health concern, though as you’ve seen with black mucus, a wide range of factors can trigger a variety of color changes. Any condition can be accompanied by several types of color changes:

The right treatment for black phlegm or mucus will depend on the cause. You may need to see a doctor, such as an ear, nose, and throat (ENT) specialist or a pulmonologist to determine where in the respiratory tract the problem exists.

At-home treatments

If the cause of your black mucus is smoking or exposure to airborne pollutants, avoiding those triggers is vital. If you smoke, quitting smoking is an important first step.

You may be advised to drink a lot of fluids and use a humidifier in your home to help loosen your phlegm so that you can cough it up.

If a serious infection is diagnosed, following your doctor’s recommendations will be essential to a healthy recovery. This means taking all your medications as prescribed and following through with all your appointments.

Medical treatments

Infections causing black phlegm and other symptoms can often be treated with medications and rest. Antibiotics are only effective for bacterial infections, such as TB and bacterial pneumonia. So if the cause of your problems is a virus, antibiotics won’t help. Antiviral medications may be effective if the cause is the flu virus. Antifungal medications work against fungal infections.

Heart-related treatments should be overseen by a cardiologist. A diseased valve may need to be repaired or replaced surgically, depending on the nature of the problem. The dosage and type of blood-thinning medications can be adjusted, but some trial and error is often necessary to find the right drug regimen.

If your lung function has been affected by other disease processes, you may need medications and other treatments, including oxygen therapy.

If you have mucus that is clear, yellow, or green, you may want to wait a few days before seeing a doctor. However, if you have other serious symptoms, such as a high fever, chest pain, or shortness of breath, or if you’ve been coughing up blood, then seek medical attention in the emergency department.

If your mucus or phlegm is black, very dark, or tinged with blood, see a doctor right away. An immediate diagnosis may not always be possible, but it’s important to get started understanding why this change has occurred.

Black mucus may be a temporary sign you’ve been breathing polluted air or that it’s time to quit smoking. But because it can also signal serious infections and major respiratory complications and conditions, it’s vital that you take this symptom seriously.

Infections can often be treated successfully, but ongoing lung conditions can be difficult to manage and will require patience.