Coughing up blood can be alarming, but isn't usually a sign of a serious problem if you're young and otherwise healthy. It's more a cause for concern in older people, particularly those who smoke.
The medical term for coughing up blood is haemoptysis.
You may cough up small amounts of bright red blood, or frothy blood-streaked sputum (phlegm). The blood is usually from your lungs and is often the result of prolonged coughing or a chest infection.
If the blood is dark and contains bits of food or what look like coffee grounds, it may be coming from your digestive system. This is a more serious problem and you should go to hospital straight away. Read more about vomiting blood.
Call your GP surgery as soon as possible if you cough up blood, even if it's just a few spots or specks.
Your GP will check if you might have a serious medical condition that needs to be investigated and treated.
Call 999 for an ambulance or go to your nearest accident and emergency (A&E) department immediately if you're coughing up a lot of blood or are struggling to breathe.
You may be asked for a sample of your sputum so it can be checked for infection. Other tests, such as blood tests, may also be needed.
In some cases, further tests may be required to find out where the blood is coming from. For example, you may be referred to a specialist who may decide to arrange a test called a bronchoscopy (where the main air passages of your lungs are examined using a tube with a camera at one end).
This page can give you a better idea of what the cause may be, but don't use it to diagnose yourself. Always leave that to a doctor.
The most common reasons for coughing up blood are:
Sometimes a severe nosebleed or bleeding from the mouth or throat can cause blood to come out in your saliva when you cough.
Less commonly, coughing up blood may be the result of:
Sometimes, no cause can be found and it never happens again.