Erectile dysfunction can occur as a side effect of medication taken for another health condition. Common culprits are high blood pressure meds, antidepressants, some diuretics, beta-blockers, heart medication, cholesterol meds, antipsychotic drugs, hormone drugs, corticosteroids, chemotherapy, and medication for male pattern baldness, among others.
A common and important cause of ED is vasculogenic. Many men with ED have comorbid conditions such as hyperlipidemia, hypercholesterolemia, tobacco abuse, diabetes mellitus, or coronary artery disease (CAD).  The Princeton III Consensus recommends screening men who present with ED for cardiovascular risk factors; ED may be the earliest presentation of atherosclerosis and vascular disease. 
Normal erectile function depends on the release of NO and endothelial-dependent vasodilation of the penile arteries. The ‘artery size’ hypothesis, first described by Dr Montorsi, offers an explanation why men are more likely to develop ED before a myocardial infacrtion. It is believed that atherosclerosis affects all vascular beds equally but smaller arteries are more likely to become occluded than larger arteries.31 32 The penile arteries are 1–2 mm while the coronary arteries are 3–4 mm. Thus, the same degree of endothelial dysfunction and atherosclerosis is more likely to occlude blood flow in the penile arteries compared with the coronary arteries. The penile arteries therefore serve as a sensitive indicator for subsequent CVD. This theory is supported by the fact that ED occurs approximately 3 years prior to cardiac symptoms in virtually all patients with chronic coronary syndrome whereas patients with acute coronary syndrome have a much lower prevalence of sexual dysfunction.32
Modern drug therapy for ED made a significant advance in 1983, when British physiologist Giles Brindley dropped his trousers and demonstrated to a shocked Urodynamics Society audience his papaverine-induced erection. The drug Brindley injected into his penis was a non-specific vasodilator, an alpha-blocking agent, and the mechanism of action was clearly corporal smooth muscle relaxation. The effect that Brindley discovered established the fundamentals for the later development of specific, safe, and orally effective drug therapies.[better source needed][better source needed]
The Massachusetts Male Aging Study (MMAS) documented an inverse correlation between ED risk and high-density lipoprotein (HDL) cholesterol levels but did not identify any effect from elevated total cholesterol levels.  Another study involving male subjects aged 45-54 years found a correlation with abnormal HDL cholesterol levels but also found a correlation with elevated total cholesterol levels. The MMAS included a preponderance of older men.
A number of herbs have been promoted for treating impotence. The most widely touted herbs for this purpose are Coryanthe yohimbe (available by prescription as yohimbine, with the trade name Yocon) and gingko (Gingko biloba), although neither has been conclusively shown to help the condition in controlled studies. In addition, gingko carries some risk of abnormal blood clotting and should be avoided by men taking blood thinners such as coumadin. Other herbs promoted for treating impotence include true unicorn root (Aletrius farinosa), saw palmetto (Serenoa repens), ginseng (Panax ginseng), and Siberian ginseng (Eleuthrococcus senticosus). Strychnos Nux vomica has been recommended, especially when impotence is caused by excessive alcohol, cigarettes, or dietary indiscretions, but it can be very toxic if taken improperly, so it should be used only under the strict supervision of a physician trained in its use.
Intraurethral alprostadil is contraindicated in individuals who have abnormal penile anatomy (for example, urethral stricture, severe hypospadias with penile curvature), patients with acute or chronic irritation/infection of the urethra, individuals prone to priapism such as those with sickle cell anemia, thrombocytopenia, polycythemia, multiple myeloma, or are prone to blood clots. Intraurethral alprostadil should not be used for sexual intercourse with a pregnant woman.
There are many alternative impotence treatments available but many of them are neither licensed nor legitimate, Beware of sellers offering “herbal” impotence treatments - these remedies do not work and are often sold illegally. You should also be wary of online sellers who offer Viagra and other prescription drugs without asking you for a prescription. Illegal pharmacies often sell counterfeit or fake medication and buying from them could put your health at risk.
Sexual stimulation causes the release of neurotransmitters from cavernosal nerve endings and relaxation factors from endothelial cells lining the sinusoids. NOS produces NO from L-arginine, and this, in turn, produces other muscle-relaxing chemicals, such as cGMP and cyclic adenosine monophosphate (cAMP), which work via calcium channel and protein kinase mechanisms (see the image below). This results in the relaxation of smooth muscle in the arteries and arterioles that supply the erectile tissue, producing a dramatic increase in penile blood flow.
Alprostadil is an FDA-approved erectile dysfunction drug that can be injected directly into the penis to trigger an automatic erection. "Penile injection is the most effective type of ED treatment for men who can't take oral treatment," says Nelson Bennett, MD, a urologist at the Lahey Clinic in Burlington, Mass. In fact, it has an 85 percent success rate. Possible side effects include a burning sensation and priapism, an erection that lasts more than four hours and requires medical treatment.
Vacuum therapy devices have a few disadvantages. One must interrupt foreplay to use them. You must use the correct-size tension ring and remove it, to prevent penile bruising, after sustaining the erection for 30 minutes. Initial use may produce some soreness. Such devices may be unsuitable for men with certain bleeding disorders. In general, vacuum constriction devices are successful in management of long-term ED.
Specially designed vacuum devices to produce erections have been used successfully for many years. Vacuum devices are safe, relatively inexpensive, and reliable. Vacuum devices do not require surgery. Vacuum devices are available over the counter or by prescription. It is important to make sure that the vacuum device have a mechanism to prevent too high of a vacuum (negative pressure).
Finally, there are NO-releasing polymers that are capable of delivering NO in a pharmacologically useful way. Such compounds include compounds that release NO upon being metabolised and compounds that release NO spontaneously in aqueous solution. Initial animal studies suggest that cavernosal injections of NO polymers can significantly improve erectile function.48
Men with medical conditions that may cause a sustained erection, such as sickle cell anemia, leukemia, or multiple myeloma, or a man who has an abnormally-shaped penis, may not benefit from these medications. Also, men with liver diseases or a disease of the retina, such as macular degeneration or retinitis pigmentosa, may not be able to take these medications, or may need to take the lowest dosage.
The association between low testosterone and ED is not entirely clear. Although these 2 processes certainly overlap in some instances, they are distinct entities. Some 2-21% of men have both hypogonadism and ED; however, it is unclear to what degree treating the former will improve erectile function.  About 35-40% of men with low testosterone see an improvement in their erections with testosterone replacement; however, almost 65% of these men see no improvement. 
Another approach is vacuum therapy. The man inserts his penis into a clear plastic cylinder and uses a pump to force air out of the cylinder. This forms a partial vacuum around the penis, which helps to draw blood into the corpora cavernosa. The man then places a special ring over the base of the penis to trap the blood inside it. The only side effect with this type of treatment is occasional bruising if the vacuum is left on too long.
In order to establish whether normal erections are occurring overnight (nocturnal erections), the doctor may organise nocturnal penile tumescence (NPT) testing. This involves wearing a monitor overnight in your own home. The data from this monitor is then assessed to analyse how often erections occurred, how long they lasted, and how rigid and large the penis was during the erections. If NPT testing is normal, the cause of erectile dysfunction is usually psychological. If not, further testing of the blood flow in the genital area may be required to see if there is blockage or leakage. The doctor may also organise a blood test of levels of hormones such as testosterone, prolactin and thyroid stimulating hormone to see if these are contributing to the erectile dysfunction.
VED involved placing the penis in a clear plastic tube where negative pressure created by the vacuum pump leads to penile engorgement and tumescence. Usually a constriction ring can be placed on the base of penis following penile engorgement. Some men complain of bruising, a “cold” penis and pain associated with the constriction ring; however, in some men with NED sensation may not be intact mitigating the side effects of VEDs. VEDs have reported effectiveness up to 90% in certain ED populations and it remains a non-invasive means to achieve and erection.
The association of CVD and ED was noted in 1997 as one analysed the results of the MMAS. In this landmark study, 1709 men aged 40–70 years were enrolled between 1987 and 1989. A follow-up some 10 years later revealed a striking relationship between ED and CVD. In this study, it became clear that the risk factors for ED were very similar to those of CVD, such as diabetes mellitus, smoking and dyslipidaemia.18
One of the first steps is to distinguish between physiological and psychological ED. Determining whether involuntary erections are present is important in eliminating the possibility of psychogenic causes for ED. Obtaining full erections occasionally, such as nocturnal penile tumescence when asleep (that is, when the mind and psychological issues, if any, are less present), tends to suggest that the physical structures are functionally working. Similarly, performance with manual stimulation, as well as any performance anxiety or acute situational ED, may indicate a psychogenic component to ED.
The neurovascular events that ultimately occur result in the inhibition of adrenergic tone and the release of the nonadrenergic, noncholinergic neurotransmitter, nitric oxide. Nitric oxide is believed to be released from nonadrenergic, noncholinergic nerves and endothelial cells. It subsequently stimulates the guanylate cyclase enzyme system in penile smooth muscle. This results in increased levels of cyclic guanosine monophosphate (cGMP) and ultimately in smooth muscle relaxation, enhancement of arterial inflow, and veno-occlusion, producing adequate firmness for sexual activity.
If a trial of oral ED therapy and withdrawal of offending medications prove to be ineffective in restoring erectile function, it is appropriate for most primary care practitioners to consider referral to a specialist for additional evaluation and discussion of alternative treatment options. These include intracavernous injection therapy, vacuum constriction devices, intraurethral therapy, and possible surgery.
One study examined the role of testosterone supplementation in hypogonadal men with ED. These men were considered nonresponders to sildenafil, and their erections were monitored by assessing nocturnal penile tumescence (NPT). After these men were given testosterone transdermally for 6 months, the number of NPTs increased, as did the maximum rigidity with sildenafil.  This study suggests that a certain level of testosterone may be necessary for PDE5 inhibitors to function properly.