Fight loneliness by going out with people. Friends, family, friends of friends, colleagues - whoever. Go to any kind of meetups to make new connections.
You can also get a pet. And take part in sites such as dev.to if you want developer dialogues (i find that they keep me on track).
Loneliness while working sucks though. You cant turn to anyone. Best you get yourself in some co-worker space, rent a desk and get around other people. These often organize things to do together as well.
Luckily I've got a solid friend group and a really understanding fiance. For me the loneliness comes from not having anyone to talk to about the work I'm doing - there are other people in the office with me, but no one else coding. Hoping to solve that by getting more involved with the local code community!
Can you hire a partner? In person or remotely.
By co-working space i meant a devs only space like this one we have: hub387.com/
But i don't believe you can leave your office and work from somewhere else, or can you?
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.