Getting an erection depends on blood flow, nerve signaling, and mental arousal all working together. When any one of those systems is off, erections can be weaker or harder to maintain. The good news is that most of the factors involved are things you can directly influence through exercise, diet, stress management, and lifestyle changes.
How Erections Work
An erection starts with a signal from the brain or from direct physical stimulation. Nerves release a molecule called nitric oxide, which triggers a chain reaction that relaxes the smooth muscle tissue inside the penis. This relaxation opens up the blood vessels (called helicine arteries), allowing blood to rush in and fill two sponge-like chambers called the corpora cavernosa. As those chambers expand with blood, they compress the veins that would normally drain blood away, trapping it inside and creating firmness.
Anything that disrupts this process, whether it’s restricted blood flow, low nitric oxide production, nerve damage, hormonal imbalance, or anxiety activating your fight-or-flight response, can make it harder to get or stay hard. That’s why erection quality is often considered a barometer of overall cardiovascular and mental health.
Aerobic Exercise and Blood Flow
Because erections are fundamentally a blood flow event, cardiovascular fitness has a direct impact on erection quality. Research from Harvard Health found that men who exercised for 30 to 60 minutes, three to five times a week, saw more improvement in erectile function than men who didn’t exercise. In fact, the effect was comparable to what some men experience with medication.
Any activity that gets your heart rate up counts: brisk walking, running, cycling, swimming, or rowing. The benefit comes from improved blood vessel flexibility and increased nitric oxide production over time, both of which make it easier for blood to reach the penis when you’re aroused.
Pelvic Floor Exercises
The muscles at the base of your pelvis play a role in trapping blood inside the penis during an erection. Strengthening them through Kegel exercises can improve both erection firmness and your ability to maintain one. These same muscles also contract during orgasm, so stronger pelvic floor muscles can improve the overall experience.
To find the right muscles, try stopping your urine stream midflow. The muscles you squeeze to do that are the ones you want to target. Once you know the feeling, practice contracting them for a few seconds and releasing. Aim for three sets of 10 to 15 repetitions per day. You can do these sitting, standing, or lying down, and nobody will know you’re doing them.
Foods That Support Erection Quality
Your body builds nitric oxide from an amino acid called L-arginine, which is found in many common foods. A meta-analysis of clinical trials found that arginine supplements at doses between 1,500 and 5,000 mg per day significantly improved erectile function compared to placebo. You don’t necessarily need a supplement to get this benefit. Walnuts are particularly rich in L-arginine, and watermelon contains L-citrulline, which your body converts into arginine.
More broadly, a Mediterranean-style eating pattern is consistently linked to better erectile function. A large prospective study of over 21,000 men found that strong adherence to this diet was inversely associated with erectile dysfunction. The pattern emphasizes vegetables, fruits, nuts, whole grains, legumes, olive oil, and seafood. Extra virgin olive oil is especially notable for its concentration of beneficial fats and bioactive compounds that support vascular health. Think of it this way: what’s good for your heart is good for your erections, because the same blood vessels are involved.
Managing Anxiety and Mental Blocks
Your nervous system has two competing modes. The parasympathetic system (rest and digest) enables erections. The sympathetic system (fight or flight) shuts them down. Performance anxiety, stress, or being distracted during sex can tip the balance toward the wrong system, making it physically difficult to get hard even when you want to.
One of the most effective approaches is called sensate focus, a technique originally developed by sex researchers William Masters and Virginia Johnson. The idea is to remove performance expectations entirely. You and a partner start with non-genital touching focused purely on sensation, with no goal of intercourse or orgasm. Over multiple sessions, you gradually add more sexual elements. By shifting attention from “Am I hard enough?” to “What does this feel like?”, you allow arousal to build naturally without the interference of anxiety.
Mindfulness during sex works on a similar principle. Instead of monitoring your erection or worrying about your partner’s experience, you practice staying present with physical sensations. This means noticing temperature, pressure, and texture rather than getting caught in evaluative thoughts. When intrusive thoughts come up (“This isn’t working,” “What if I lose it?”), the goal is to acknowledge them without latching on, then redirect your attention back to what you’re feeling. Creating a distraction-free environment helps: phones off, lights how you prefer them, enough time that neither of you feels rushed.
Cognitive restructuring is another tool. Many men carry beliefs like “I should be able to get hard instantly” or “If I lose my erection, the whole experience is ruined.” These beliefs increase pressure and make the problem worse. Actively identifying and challenging these thoughts can break the cycle. The reality is that erections naturally fluctuate during a sexual encounter, and losing firmness temporarily is normal, not a failure.
Sleep and Testosterone
Testosterone plays a supporting role in sex drive and erection quality, and your body produces most of it during sleep. A meta-analysis of sleep deprivation studies found that going 24 hours or more without sleep significantly reduces testosterone levels. Even 40 to 48 hours of total sleep deprivation caused a further drop. The American Academy of Sleep Medicine recommends at least seven hours per night for adults.
Interestingly, short-term partial sleep restriction (sleeping less than ideal but still getting some sleep) didn’t significantly lower testosterone in the same analysis. So missing a few hours one night probably won’t affect you much, but chronically poor sleep over weeks and months can erode the hormonal foundation that supports healthy erections.
When Lifestyle Changes Aren’t Enough
Prescription medications called PDE5 inhibitors work by blocking the enzyme that breaks down the chemical signal responsible for keeping blood vessels in the penis relaxed. This makes it easier to get and maintain an erection in response to sexual stimulation (they don’t cause an erection on their own). The most commonly prescribed options take effect within 30 to 120 minutes. Some last about 4 hours, while one longer-acting option lasts up to 36 hours, giving more flexibility around timing.
Doctors sometimes use a five-question screening tool to gauge severity. Scores range from 5 to 25, with 22 to 25 indicating normal function, 17 to 21 suggesting mild difficulty, and anything below 12 pointing to moderate or severe dysfunction. If you’re consistently struggling, that score can help guide whether you’d benefit from medication, therapy, or both. Erectile difficulty that comes on gradually is more likely related to blood flow or hormonal issues, while difficulty that appears suddenly or only happens with a partner (but not during sleep or masturbation) often has a psychological component.