For me it's more specifically not having any possibility of getting a gf than general loneliness but I suppose if you'd have a gf you wouldn't be lonely in general, either. This is something that can theoretically be solved, at least the not having friends part, but it might be tough. First off, it's more likely that we'll get friends if we are relatively content and interested in others. So, if we have depression and are wallowing in our own misery it's good to take care of that before starting to attend social events or attempting to. Easier said than done, but I think this is a good first step. Comes down to becoming ok with our daily life and having some basic level of self-esteem and confidence.
Now, some people might find luck in doing it the other way around. Fixing themselves up temporarily and getting out there first, letting the inner stuff work itself out later, idk.
Maybe it would be good to do a bunch of research online and finding social success stories of people similar to you. Then there's the possibility of getting really into some hobby that involves social interactions, as well. Again, to get from acquaintance to friend will be helped by not being suicidally depressed so that's a priority.
I think the biggest thing is to not get overwhelmed by how much we feel we need to change, but to instead take it one day at a time and slowly develop into someone that's capable of making friends. One visit to the gym there, one round of tennis here (I don't know what normal people do for fun), waking up at the same time every day, whatever it is you feel will boost your self-esteem and confidence.
Meditation maybe, writing a diary, talking to yourself, etc.
Not trying to give you a to-do list or anything, I don't follow my own advice but I've basically given up on social stuff atm.