Being isolated is the price we pay for being allowed to escape from abusive communities. If you are stuck with people who hurt you, that sucks. So it seems like the best way to prevent people from being locked in hell is to make communities optional.
The problem is, it is very difficult to coordinate the creation of a community. Whatever you think should be its boundaries, someone within the proposed boundaries will disagree with you. Actually, most of them would disagree with you, and each of them for a different reason. The end result is usually that there is no community. Sometimes, an external force (such as school or army) temporarily creates an involuntary community, where the people find each other's company pleasant, so the community remains even after the external force is gone.
Should you base the community on common education/profession? Or rather common values? Hobbies? Age? Geographical proximity is important, too, because then you can meet in person, organize things together, discuss local things. But each of these choices makes you compromise on the other ones.
Even on personal level, sometimes person A enjoys the company of person B; person B enjoys the company of person C; but the person C hates person A. So the approach "instead of defining some unifying principle, just base it on personal chemistry" fails, too.
Maybe we are unable to construct a community, so the best we could do is just throw a few random people together, make them stay together for a few weeks, and then leave it up to them whether they want to keep contact with each other. I could imagine doing this as a service: organize the lottery that assigns people to each other; rent them the place they can continue meeting each other once a week.
But still, where can an average person find "a few weeks" of time necessary to build the community? (Yeah, in a job, but job-based communities are problematic; if you lose a job, you lose your community, too, at the very moment you might need their support most.) Or would one day a week be enough? Sign up to become a community member, promise to spend the following 12 Friday evenings in our place, meet the same group of randomly selected people who also subscribed for the same service... and hopefully start something that can survive a few years? Not sure this would work. (Among other things, it might select for the most desperate people, who ultimately wouldn't desire to have a community with each other.)
I can't even solve this problem for myself, so I can't give advice to entire society. If I dared, I would encourage people to have more hobbies, and perhaps to reduce the work time, so that people have more time for their hobbies and communities.