Illicit drugs are marketed both via dark web platforms and social media, but there are also research reports buying these drugs online. This study is intended to analyse the risk factors for the purchase of online illicit drugs. We assumed that social interactions, low levels of self-control, and impaired mental health would be correlated with online opioid sales following criminological and addiction analysis research. Moreover, online drug sales are expected to be related to low self-control and daily drug consumption. Participants in this nationwide study were aged 15 to 25 years and lived in Germany (N=1,732) and France (N=1,732). Measures of impulsivity, ability sensitivity, social association, psychological tension, and repetitive activity (drinking, gambling, and Internet use) predicted online drug use. 4% of German and French respondents reported buying drugs online of which, 63% did so via social media services. Online opioid purchases were associated with lower self-control, elevated social anxiety, heavy gambling, and Internet use, as shown by multinomial logistic regression and binary intervention regression models. It was not a risk factor to have online friends, but close social links with offline friends served as a security factor. The results indicate that more attention should be paid to mainstream social media services as a source for buying drugs as there are many psychological and self-control issues among online drug consumers.