Coughing up blood is also known as hemoptysis.
Coughing up blood can be caused by a variety of lung conditions.
The blood may be bright red or pink and frothy, or it may be mixed with mucus.
Bloody sputum is a noticeable symptom - in order to diagnose the underlying cause and prevent any possible complications, you should consult a doctor in a timely manner.
Coughing up blood, even in small amounts, can be alarming. Seek emergency care if you're coughing up blood in large quantities or at frequent intervals.
Causes
Hemoptysis refers to coughing up blood from some part of the lungs (respiratory tract).
Blood coming from elsewhere, such as your stomach, can appear to be from the lungs. It's important for your doctor to determine the site of the bleeding, and then determine why you're coughing up blood.
The major cause of coughing up blood is chronic bronchitis or bronchiectasis.
Possible causes of coughing up blood include:
- Chronic obstructive pulmonary disease
- Cystic fibrosis
- Drug use, such as crack cocaine
- Foreign body
- Granulomatosis with polyangiitis (Wegener's granulomatosis)
- Lung abscess
- Lung cancer
- Mitral valve stenosis
- Parasitic infection
- Pneumonia
- Pulmonary embolism (blood clot in an artery in the lung)
- Trauma to the chest
- Tuberculosis and etc.
Source:
https://www.mayoclinic.org/symptoms/coughing-up-blood/basics/definition/sym-20050934