How should Buddhists deal with Loneliness
Overall, the Buddha says:

MN128:6.30: If you find an alert companion,  a wise and virtuous friend, then, overcoming all challenges, wander with them, joyful and mindful. If you find no alert companion, no wise and virtuous friend, then, like a king who flees his conquered realm, wander alone like a tusker in the wilds.

Rarely do we have to &quot;wander alone like a tusker in the wilds.&quot; Spiritual friends often enter our lives when we take the time to recognize them as such.
But the above advice works best for those committed to and firmly on the path. For others struggling with day to day issues it's more challenging given the need to maintain relationships to simply survive. Surrounded by materialistic pursuits and people, alienation and loneliness can overwhelm. If sangha and/or teacher are not available to you locally or even online, then you may very well be a &quot;tusker in the wild.&quot;
To build deep, trusting and long-lasting relationships requires ethics. On the path we practice ethics, immersion and wisdom. Ethics define our relationships with others. When we behave ethically, others trust us and relationships grow.
Ethics is surprisingly complicated. In MN8, the Buddha declares forty-four (44!) things to attend to. The list starts with:

MN8:12.2: ‘Others will be cruel, but here we will not be cruel.’

Indeed, for this online age, the following seem quite appropriate:

MN8:12.8: ‘Others will speak harshly, but here we will not speak harshly.’
MN8:12.9: ‘Others will talk nonsense, but here we will not talk nonsense.’
MN8:12.10: ‘Others will be covetous, but here we will not be covetous.’

There are a lot more in that sutta. I read it regularly to refresh my perspective. Perhaps that may help you as well.