Social animals expend considerable energy to maintain social bonds throughout their life. Male and female mice show sexually dimorphic behaviors, yet the underlying neural mechanisms of sociability and their dysregulation during social disconnection remain unknown. Dopaminergic neurons in dorsal raphe nucleus (DRNTH) is known to contribute to a loneliness-like state and modulate sociability. We identified that activated subpopulations in DRNTH and nucleus accumbens shell (NAcsh) during 24 hours of social isolation underlie the increase in isolation-induced sociability in male but not in female mice. This effect was reversed by chemogenetically and optogenetically inhibiting the DRNTH-NAcsh circuit. Moreover, synaptic connectivity among the activated neuronal ensembles in this circuit was increased, primarily in D1 receptor-expressing neurons in NAcsh. The increase in synaptic density functionally correlated with elevated dopamine release into NAcsh. Overall, specific synaptic ensembles in DRNTH-NAcsh mediate sex differences in isolation-induced sociability, indicating that sex-dependent circuit dynamics underlie the expression of sexually dimorphic behaviors.