Men get erections from increased blood flow to the penis, triggered by arousal or involuntarily during sleep and at other times.
How an erection works
Arousal sends nerve signals that relax penile arteries. Blood fills the spongy tissue and traps it, causing hardness. Nitric oxide drives this.
Involuntary
Erections also occur during REM sleep, 3 to 5 times a night.
Causes
Touch, thoughts and hormones.
Age
Frequency decreases with age.
See a doctor
If you have trouble getting or keeping one, which can signal heart disease or diabetes.

Physiology of erections
An erection occurs when nerve signals cause the arteries in the penis to relax and widen. Blood fills spongy erectile tissue (corpora cavernosa), and the veins that normally drain blood are compressed. Nitric oxide triggers the process by increasing cyclic GMP, which relaxes smooth muscle. This is how drugs like sildenafil work.
Reflex and psychogenic
There are two main routes: psychogenic erections from thoughts, images or arousal, and reflex erections from touch. A spinal reflex can cause an erection with no sexual thoughts, even in some people with spinal cord injuries.
Spontaneous erections
Erections can occur without arousal, because of hormones, touch from clothing, a full bladder or REM sleep. They are common in teenagers and young men, who may have many a day, and these tend to decrease with age.
Hormones

Testosterone supports sexual desire and the frequency of spontaneous erections but is not the only factor. Levels peak in the morning.
Age
Erectile function typically declines gradually after 40. The Massachusetts Male Aging Study found that about 52% of men aged 40 to 70 had some degree of erectile dysfunction.
Problems
- Erectile dysfunction: trouble getting or keeping an erection, linked to heart disease, diabetes, high blood pressure, medications, stress, smoking and alcohol.
- Priapism: an erection lasting more than 4 hours, which is a medical emergency and can cause permanent damage.
Healthy habits
Exercise, a heart healthy diet, not smoking, limiting alcohol and managing stress all support erectile function.
See a doctor if
Erection problems persist for more than a few weeks, occur suddenly or come with pain or curvature (Peyronie’s disease). Erectile dysfunction can be an early sign of cardiovascular disease.
How the mechanism works
An erection happens when sexual stimulation or reflex signals cause nerves to release nitric oxide, which relaxes smooth muscle in the penis and allows blood to fill two spongy chambers, the corpora cavernosa, compressing veins to trap blood. Erections can be psychogenic, caused by thoughts, or reflexogenic, caused by touch, and they also occur spontaneously during REM sleep. Boys and men can have unprompted erections, especially during puberty, when testosterone levels rise, and this is normal.

Health and problems
Testosterone supports sexual desire, though erections depend more on blood flow and nerves. Erectile dysfunction affects about 30 million US men and becomes more common with age, diabetes, heart disease, smoking and some medicines. Drugs such as sildenafil, approved in 1998, work by enhancing the nitric oxide pathway. An erection lasting more than 4 hours (priapism) is an emergency. Regular exercise, healthy weight, not smoking and managing blood pressure and diabetes support function. See a doctor for persistent changes or pain.
Based on data from the NIDDK and the Urology Care Foundation







