I have a hypothesis about this type of feeling but it is work in progress and probably not finished.
I think one primary reason why we feel this loneliness is because we fear the situations where we might need other people, in particular situations where we do not have a computer or we are sick or otherwise unable to live the way we usually do on the computer (speaking for HN crowd specifically) ;P
What i mean by this is for example I can imagine myself getting sick or getting old to the point where I can't do the things I am passionate about, so I end up sitting alone somewhere just staring out the window or something, with no friends or family, and that is a pretty lonely thought.
The problem in the modern world is that we can for the most part actually live alone and do the things that we are interested in, and these situations where we actually need other people in person become an abstract idea rather than a concrete need, but historically and probably evolutionary we did need them. I think in prior decades it was a lot harder to entertain yourself and be alone as much as we are today. We can get a hold of food, social interactions online and accomplish goals in a way that was never possible without in person interaction in the past and this confuses our brain which is not used to this arrangement. Edit: Just to make it clear, I think we oscillate between feeling complete happiness and contentment from the things we do alone and enjoy (like coding/reading/whatever you do), and the feeling of being afraid of the moments we might need people. It is this oscillation pattern that confuses our brain because we don't know if what we have is enough or not. We want to "cover" all possible scenarios we can imagine.
I also want to mention the feeling we've all probably had when we do something on our own that was a challenge and we succeeded - it gives a strong feeling of relief when we actually accomplish this. I think, if we can get that feeling for ALL life situations we would no longer feel loneliness since we would be self sufficient in all situations. But up until we are convinced of this, we will always be afraid of the abstract imaginary situation where we will need other people but will be alone I think.
So i think there are two possible solutions -
1) Either convince yourself through experience or thought that there is no situation you cannot deal with alone and it will be fine
or
2) Do the hard work of making and keeping friends which means sacrificing your own time and thoughts etc to them. This is like studying for a test in a boring subject there is no way around it. Don't get me wrong I don't think other peopel are boring I just mean there is work needed there that usually goes beyond the comfort / convenience level of what you're used to.
Tbh I am far from good at this, I am mostly alone nowadays but I do enjoy talking to some select few people, but I try to keep the fear mentioned above in check and also be content that I can handle the situation I am in and future ones.