tl;dr via finding places to belong & if that's not possible, by accepting it & focusing on things that I can do alone. Also by having a healthy mental "script" about failure/disappointment/lonliness, etc.
Lot of sad but true and familiar sentiments here, and it's an evocative topic.
The best method I have found is to build on common interests. If I have an interest in common with someone, then in some regard I belong. If at some level I don't belong, then I do my best to accept it and be happy with myself. It turns out that is a worthwhile pursuit in itself, and one that I may not have benefited much from had I not felt alone and forced to face it. Also, the "special interest" trait comes in handy there as I can be happy to be absorbed in something, by myself.
I've met some decent friends & had many memorable experiences through something as simple as Meetup.com. However I do live in an urban area large enough to support meetups for what I am interested in. I think living in a less-populated area would be very limiting in this regard. The internet is great for connecting with special interests, as we all know, even if we don't meet in person.
It is draining to put myself out there and to go meet strangers (or even friends... lol), but the fact is that it's required, if you want to become part of a group. There is an initial cost and there is upkeep too. Upkeep on friends, it sounds bad, but it's true, and it's worth it (unless you are the only one paying it). There is also pain to be found, even when you belong, when there are misunderstandings or things fall apart. That is inseparable, and as such, should be accepted.
So it's been a mixed bag and I don't regret my efforts, which have failed one way or another more often than they've succeeded. That's just a fact of life, not something negative. Someone said, you will fail, you might succeed, and you should learn. To me, that's a healthy perspective. Life is hard. You have to struggle to make it, success is not guaranteed, but it is possible, and if you look at failure as a learning opportunity then you will succeed more often. There's no point getting down about it (though that's easier said than done).
I've been fortunate to have had some very good friends, though even with them I've at times felt completely alone. In the end, in a way, we are. But this should not discourage us from trying to connect with what we need.