Coughing up blood in mucus, or hemoptysis, can be caused by physical conditions, diseases and some medical tests, according to MedlinePlus. This includes medical issues such as pneumonia, tuberculosis, cancer, bronchitis and a blood clot in the lung.
Other possible causes of coughing up blood in mucus include breathing foreign matter into the lungs such as food; cystic fibrosis; injuries to the arteries in the lung; and pulmonary edema, states MedlinePlus. Tests such as a bronchoscopy accompanied with a biopsy or severe coughing that causes throat irritation can also cause hemoptysis. As blood is coughed up, it is mixed with air and mucus, causing an aerated look. The blood may look bright or appear rust-colored, or it may only appear as streaks in the mucus.
It is important to seek medical attention for coughing up blood accompanied by fever, dizziness, chest pain or acute shortness of breath, explains MedlinePlus. Hemoptysis accompanied by blood in the urine or stool, lightheadedness or produces more than a few teaspoons of blood also requires immediate medical attention. Even without other symptoms, a person experiencing hemoptysis should call a doctor to report the condition. Tests that may be performed as a result of coughing up blood include a complete blood count, chest X-ray, a sputum culture or lung biopsy.