Coughing up thick, green mucus may mean a bacterial or, less often, viral infection, but that's not always true. You ...
“Green or yellow phlegm can occur with an infection ... Most phlegm can be coughed up or swallowed safely, so it’s up to ...
So it’s not out of the ordinary to cough up mucus from time to time. But if the mucus is thick or a different color (green or yellow), it could be a sign of pneumonia or bronchitis.