Pulmonary edema is caused by excess fluids in your lungs. It occurs when the air sacs (alveoli) in your lungs fill with fluid. The fluid buildup makes it hard for the lungs to do their job, including getting oxygen from the air you breathe and moving it through the body. This makes it hard to breathe. Pulmonary edema can happen suddenly, or it may develop slowly over time.
The most common cause of pulmonary edema is heart failure. When the heart isn't able to pump efficiently, it can cause pressure to rise in the veins (blood vessels) of the lungs. As pressure builds, fluid leaks out of the congested veins. It fills the alveoli. The extra fluid prevents oxygen from moving through the lungs as it should. But heart failure isn't the only cause of pulmonary edema. Damage to the lungs or kidney failure can also cause fluid to fill the lungs. And in some cases, living or exercising at high altitudes can lead to fluid buildup in the lungs.