Background Alopecia areata (AA) may be related to stress and has been reported to be associated with psychiatric disorders. Nevertheless, a nationwide study of the relationship between AA and comorbid psychiatric diseases has not been conducted, and the effect of onset age has rarely been reported. Objectives To analyse the associations between AA and various psychiatric disorders using a nationwide database in Taiwan. Methods Data were obtained from the National Health Insurance Research Database of Taiwan from 2000 to 2009. In total, 5117 patients with AA and 20 468 age- and gender-matched controls were enrolled. Results Patients with AA tended to have more coexisting anxiety and less comorbid schizophrenia. Differences in ages of onset revealed differences in comorbidities. An increased risk of depression [odds ratio (OR) 2·23; 95% confidence interval (CI) 1·09-4·54] was found in patients with AA aged < 20 years. An increased rate of anxiety (OR 1·43; CI 1·15-1·77) was observed with AA onset between the ages of 20 and 39 years. The highest odds of obsessive-compulsive disorder (OR 3·00; CI 1·11-8·12) and anxiety (OR 2·05; CI 1·56- 2·68) were observed in patients with AA aged 40-59 years. Moreover, about 50% of psychiatric disorders occurred earlier than AA. Conclusions AA is related to various psychiatric disorders. Onset age of AA is an important factor in the association with different comorbid psychiatric diseases. In addition to cosmetic impact, which may bring about anxiety or depression, stress neuroendocrine immunology may play an important role in the pathogenesis of both AA and psychiatric disorders.