I remind myself that emotions, including loneliness, are ultimately transient, and loneliness won't actually kill me. With time and effort, it will eventually pass. Reducing the intensity makes it easier to think of solutions. For me, loneliness is most intense when I discover something exciting to explore or share, and I realize I have no one to share it with. When that happens, I attempt to make contact with people that are likely to value the things that I value, by joining specific clubs or talking online. In the intervening time, reading books about my interests reminds me I'm not alone in them. I also go out for walks, and look at the stars. I examine nature and contemplate how vast the universe is, and how much of it I haven't seen yet. When I feel up to it, I take risks, and talk to strangers in museums or bookstores about things that we're both there to enjoy. I make sure I'm eating well, sleeping, and bathing, so physical necessity does not compound the problem.
I remind myself that objectively, each of us is always 'alone'. Life as a conscious biological organism is a solitary affair - we can communicate information and interpret the behavior of others, but they are not in my head, and they are not physically me. So, since the feeling is technically correct, but emotionally negative, and yet some people (transiently) feel emotionally happy and lack loneliness, I deconstruct the contents of my feeling so that I can consider realistic solutions. I label the feeling with shades of other, progressively more precise words that describe my emotions, like a desire for intimacy, conversation, physical company, laughter, games, affection, etc. I think of ways to solve each aspect of the feeling a piece at a time. Then I try a tactic to gain what I want, evaluate the results, alter my strategy, and repeat it until something works. Sometimes I do research or, if I can, ask others in the situation what they felt and observed. Persistence has been the most crucial element of success.