A study published in May 2014 in The Journal of Sexual Medicine found that some men can reverse erectile dysfunction with healthy lifestyle changes, such as exercise, weight loss, a varied diet, and good sleep. The Australian researchers also showed that even if erectile dysfunction medication is required, it's likely to be more effective if you implement these healthy lifestyle changes.
If you're regularly having trouble getting or maintaining erection and it's not situation specific (for instance, this happens whether you're with a partner or alone or watching porn or whatever), it could be a tip-off to a physiological problem. Diabetes, high cholesterol, high blood pressure, and cardiovascular issues can all present with erectile problems, says Paduch. That's because basically anything affecting your nerves or blood flow can impact your boners.
Qaseem, A., Snow, V., Denberg, T. D., Casey, D. E., Forciea, M. A., Owens, D. K., & Shekelle, P. (2009). Hormonal testing and pharmacologic treatment of erectile dysfunction: A clinical practice guideline from the American College of Physicians. Annals of internal medicine, 151(9), 639-649. Retrieved from http://annals.org/aim/article/745155/hormonal-testing-pharmacologic-treatment-erectile-dysfunction-clinical-practice-guideline-from