Erectile dysfunction is caused by problems with blood flow to the penis, nerve signals in the body, hormone levels, or psychological issues. During arousal, signals from the brain cause blood vessels in the penis to widen and let in more blood, making the penis hard. The veins are then compressed to maintain the erection. Common causes of erectile dysfunction include diseases like diabetes or damage to the nerves, blood vessels, muscles, or tissues of the penis. A doctor can diagnose erectile dysfunction through a medical history, physical exam, and tests. Treatments may include oral medications, counseling, injections, devices, or surgery.