Your kidneys have a network of tubes that make urine by filtering your blood in two stages. In the first stage, water, salt and waste products such as urea are filtered out from your blood, leaving behind red and white blood cells. A lot of nutrients and other essential substances also leave your blood at this stage.
In the second stage, your kidneys re-absorb these nutrients and essential substances back into the blood. This leaves waste products, plus some salt and water (urine) in your kidneys. The urine travels down tubes to your bladder where it's stored until you go to the toilet.
Heart failure can make your kidneys re-absorb more water and salt into the blood, and so produce less urine. This is your body's way of trying to compensate for the reduced pumping power of the heart, but it can make matters worse. There is a greater volume of blood for your heart to pump, and so more work for it to do. Also, excess water in the blood can leak out into your lungs, making you feel breathless (pulmonary oedema) and into the legs causing your ankles and feet to swell up (peripheral oedema).