This research aims to investigate the relationship between virus seropositivity and the occurrence of erectile dysfunction (ED). We obtained data from the U.S. Centers for Disease Control and Prevention's National health and nutrition examination survey regarding ED, hepatitis A, herpes simplex virus type 1, herpes simplex virus type 2, and cytomegalovirus, along with sociodemographic variables. We then evaluated the associations between ED and viral exposure using adjusted multivariable models. A total of 3184 participants were included in the subsequent analysis. In this study, males with ED were found to have lower levels of education, were married or living with partner, belonged to a lower socio-economic status, had a less physically active lifestyle, were smokers, and also had diabetes (all with a significance of P < .05). Our study investigating the relationship between Hepatitis A seropositivity and ED found that patients with Hepatitis A seropositivity had a higher likelihood of experiencing ED. This link remained statistically significant even when accounting for various other factors (odds ratio [OR] = 1.98; 95% confidence interval [CI] = 1.65-2.36; P < .0001). Additionally, we found that exposure to cytomegalovirus (CMV), determined by the presence of anti-CMV IgG antibodies, was also associated with ED (OR = 1.47; 95% CI = 1.14-2.25; P = .0329). This relationship remained significant after accounting for various covariates. In contrast, no associations were found between ED and seropositivity for herpes simplex virus type 1 (HSV-1) or type 2 (HSV-2) in the sample (all P values < 0.05). This study found that seropositivity for Hepatitis A or CMV is associated with ED.