Opioid use disorder (OUD) has become a leading cause of death in the US, yet current therapeutic strategies remain highly inadequate. To identify novel potential treatments for OUD, we screened a targeted selection of over 100 drugs using a recently developed opioid self-administration assay in zebrafish. This paradigm showed that finasteride, a steroidogenesis inhibitor approved for the treatment of benign prostatic hyperplasia and androgenetic alopecia, reduced self-administration of multiple opioids without affecting locomotion or feeding behavior. These findings were confirmed in rats; furthermore, finasteride reduced the physical signs associated with opioid withdrawal. In rat models of neuropathic pain, finasteride did not alter the antinociceptive effect of opioids and reduced withdrawal-induced hyperalgesia. Steroidomic analyses of the brains of fish treated with finasteride revealed a significant increase in dehydroepiandrosterone sulfate (DHEAS). Treatment with precursors of DHEAS reduced opioid self-administration in zebrafish in a fashion akin to the effects of finasteride. These results highlight the importance of steroidogenic pathways as a rich source of therapeutic targets for OUD and point to the potential of finasteride as a new treatment option for this disorder.