I know that feeling well.
Being alone is lonely.
So you make up your mind to go looking for people. You find some.
And then you're terrified of getting rejected again, and exhausted from trying to put on the proper show to avoid rejection, and STILL lonely because the person who is in the company of these people isn't you. There's a difference between putting your best foot forward and being civil and treating others with respect and NOT BEING YOURSELF.
Which is, to be frank, even worse than being lonely. It's like being agonizingly reminded of the fact that you are so damn alien that you will ALWAYS be lonely, that there is no one with whom you can connect.
I think that, other than a handful of brief instances that will be engraved on memory forever, that condition is just the normal part and parcel of Life On the Spectrum.
Or maybe The Human Condition, and it's just more common and more pronounced for us. Like, "normal" people have relatively short spells of feeling that way, while enjoying some sense of belonging the majority of the time; OTOH, our kind have relatively short spells of enjoying some sense of belonging, while feeling completely cut off, alone, isolated, and lonely most of the time.
I haven't found a remedy for that. I try to remember that I'm "getting the same connectedness" that other people get, and through no fault of anyone's I'm just not able to benefit from it the way that others do. That way at least I don't get mad at or blame them (or myself) for what none of us can help or control. Autism=lonely, even when not alone.
I read a lot of books. Lots and lots and lots of books.
Try to help people when I can.
Talk to [God] a lot. Regardless of who created whom, it helps. For me.
I hang out with my kids. Other than parent/child love, I don't EXPECT to feel a deep emotional or philosophical bond with the next generation, so I don't miss it. I don't know if they do or not. They do not appear to feel unloved, unsupported, or unaccepted to anyone I know.
I walk a lot. Think about humans as a whole. It is easier for me to feel connected to an abstract philosophical construct like Humanity than to feel truly close to any actual individual human being, living or dead.
If it helps any, I don't think it's something that you're doing wrong that causes it. I think it's just a thing that is, like freckles or congenital blindness or being left-handed.
_________________
"Alas, our dried voices when we whisper together are quiet and meaningless, as wind in dry grass, or rats' feet over broken glass in our dry cellar." --TS Eliot, "The Hollow Men"