I'm kind of going through the opposite. I was alone until 38, and then suddenly I wasn't alone anymore. I'm now realising that I did indeed develop an effective strategy to combat loneliness over the years.
What you need is a personal project. A lot of people make the mistake of thinking this needs to be something with significant utility, but that's a lot of pressure to put on yourself. My recommendation is to make your project as specific to your life as you want, and as dumb as you want. It could be a radio station localised only to your house, or a chat app for you and three other people, or a mechanical toy for a friend. Then find some friends or a community you can share that thing with when you're done.
Think about what it would be fun for you, specifically, to do, or to make, or to achieve, go do that thing, and then share it. This technique got me through 38 years of loneliness (mostly) unscathed, so I'm confident it can work for others too.