There are some generic answers (e.g. volunteer, join a club, go to bars), but I want to hear some more detail from people who have managed to find new friends and activities in new places. What worked for you and what didn't? How long did it take before you developed enough connections to keep loneliness at bay?
There's an old saying. Cliches only become cliches through repetition, they start out as obvious truth.
Volunteer is a cliche. Yes. Done that. Worked, repeatedly. Worked for me as a guy who had recently been released from prison to a city I had never lived in. I had the benefit of some specialized knowledge about swimming pools at a time when the city was in the midst of developing a city pool, and ended up as a volunteer technical consultant. That got me into conversations with a number of city staff people, and when you are listed as "known helpful" by city staff people in fairly short order you know
everybody. Worked again when I left there and came back to the city of my birth to take care of my parents...where none of the friends I grew up with ever had any intention of returning and we had not ever kept in touch. Without an appropriate city project I just signed up for a "get to know your city government" program that was organized by the city's volunteer coordinator...guess what her motives were. No coincidence that everyone in the program ended up involved in various volunteer efforts. Pro tip: "volunteer workers" are almost always more interested in standing around chatting than they are in actual working.
Join a club is a cliche. Yes, done that. I was a season ticket holder and member of the booster club for the local hockey team and developed friendships with players. Nothing like a little secondhand fame to open doors. I joined Mensa, which worked out well enough until two of the people who were members when I got involved with the local group broke up and I ended up living with one of them; not in a platonic way. I also had the benefit of working at the local university in the athletic department so was an unofficial member of the booster club there as well. Friend of the library. Sponsor of various high school teams. Long list.
But the most important cliche of all...to have a friend you have to be a friend.
Meeting a lot of people doesn't give you a lot of friends. Being available when those people call you is what makes them your friends. When I was very young in my adulthood; still going to schools in the navy so maybe twenty, tops, a guy in my class went to jail on a Friday night for driving like an idiot. Our class had a football game on Saturday against another class (off book) and when he didn't show I heard about it from a guy that was with him but not in the car for the race. At the time ATMs were a pretty new thing and not a lot of people had them...checkbooks were still standard equipment. ATM withdrawals had limits that were pretty low. It took talking eight people into tapping their cards to put together the five hundred cash to bail him out by Sunday afternoon so he could show up for muster Monday morning. Missing muster because the civilians had locked him up would have punched his ticket directly out of the program we were in.
When they turned him loose the guy about fell over to see that it was me standing there, because he thought of me more as 'just a classmate' than really friends. He emptied his own account on Monday so I could pay everyone back, and eventually did a little community service gig to settle things with the civilian cops. He had to suck some feces from the school administration for it, but since it didn't directly impact his performance he didn't get kicked out. It wasn't my intention, but I'm pretty sure that guy would have taken a bullet for me, and I'm rock solid positive he'd have delivered one.