there isn't a loneliness epidemic. There is a diffuse inability to stay truly alone. Acquiring that ability would also teach how to not stay alone when needed.
Otherwise, people wouldn't resort to social media. Going to party aimlessly and hanging out isn't necessarily better. It depends on who you hang out with and what you do.
This is just my opinion, of course.
You need both. My sense is that only a minority of people are hardwired to preferably live as hermits. And whilst it's an important life skill to be happy alone, everyone has their breaking point, it's no coincidence that one of the best predictors of longevity is how rich ones social life is.