Loneliness is painful, and it when its at its extreme it can feel like physical pain rather than mental pain. The reason for this is that humans have evolved, as with other mammals, to be sociable and to be liked. Being able to fit in and be part of a group could very often mean life or death for our ancestors, yet we still feel it, even though loneliness nowadays doesn't mean being expelled from a tribe and completely isolated from all humanity. And loneliness affects all people from all walks of life, such as Tom Hanks, as he mentioned it on Desert Island discs, where he was actually brought to tears.
I don't think there is a hard and fast cure to loneliness, I believe that the vast majority of people experience it some point, and it increases as we age. I never felt lonely before I got divorced and started living by myself. But now it crops up every now and again. The way I deal with it is to accept it as a part of life, and that I should be able to cope with it by myself, and look for my own solutions to my own problems. But I'm not able to eliminate it completely, and at times its bite stings more than at other times and all I want to do is sleep.
Though some things can help, such as hobbies. If you go to a forum which is of interest to you then you'll speak to others who share the same interests. The workplace is different in that we are put together with random people who may or may not share any of our interests, and so communication can be difficult, let alone build a friendship.
Photography is how I deal with loneliness. I like going into the woods to photograph insects and animals, even though I'm alone, it doesn't feel like I am. Sometimes I take photos in parks as well, and I also drink a couple of gins before going to make me feel more at ease. Reading is another coping strategy, but loneliness doesn't seem to feature much in ancient works which I like to read the most (or only read to be honest) as people lived in communial houses or were constantly at war among thousands of their comrades, so they were always with others.
Loneliness must have been amplified in recent generations as more and more people live alone, and why the internet can provide some sense of comfort, it isn't a substitute for real relationships, and some say that the internet and social media heightens the feeling of isolation and loneliness, and I do feel much better now that my FB is left largely dormant, and I don't use any other social media.
Take comfort at least that you are not alone in the sense of feeling alone. If I could give you better advice I would, but to be honest I don't know the answer myself. Somethings in life just have to be endured, like pain, however they can be reduced to bearable levels. But do some research from other sites on loneliness and practice what information you find which is applicable to your situation. As loneliness, like pain, can be the result from any number of causes, and so why loneliness can feel the same for everyone, the root cause may differ, and so like any other cause of pain, often requires a different remedy.
One final tip would be to identify when you feel most alone, and prepare yourself beforehand. Have something you find interesting to do during the most difficult periods, or some kind of coping strategy that you feel can at least make the seemingly unbearable, bearable.