Being lonely is difficult. A lot of people will try to tell you that it is not or that you should be OK with it. Unfortunately, a lot of this advice is moralizing, the sort of "there must be something wrong with you if you can't be by yourself for long periods of time." This really annoys me. There is nothing wrong with wanting to spend time with people! Being social is one of our most fundamental needs. But just look at all the negative health benefits loneliness brings about[1]. If you wouldn't be OK with a friend smoking 15 cigarettes a day, you probably shouldn't be OK with yourself being lonely for most days.
Humans are social animals. Yes, some people are not like this. But if you feel unhappy when you are alone, there is nothing wrong with you. This only means that you are normal.
That aside -- what do you do when you are lonely? "Easy": Go to places where there are people doing stuff and join them. Eventually you will make weak connections. Ask these people to hang out in other contexts. You are done. There are no tricks. The hard part is it takes effort and time - you need to show up over weeks or months, and following up with people outside of the event and making plans is effortful.
If you want one really targeted tip: I love pickleball. Unlike almost any other sport, pickleball has a community where you can just wander over to a pickleball court and join in with virtually anyone. Also, it's great exercise, so even if you don't meet anyone you like, you still got healthier anyways - it's a win-win.
[1]: https://www.psychologytoday.com/us/blog/the-human-beast/2023...