I'll tell you working on a master's was really invigorating for me. Some of the mental flexibility or plasticity returned that I hadn't felt since I got established in my work. I'd recommend it to anyone, though like everything else it's so much better when you can meet in person.
The PhD on the other hand is more like a regular job. That's not to say it's a bad job but it's more about getting things done than just taking time to grow in your knowledge.
For me it was team sports or group hobbies, in non-pandemic times, anyway. Search for something that interests you and see if groups in the area exist for it. You always at least have the focus of the group in common with everyone there, and through which you make friends, and meet their friends, and create a new (real) social network.
And if the group's not for you, you can just stop going and find a different one. That's a lot harder to do with something like graduate school (speaking from experience).
I'd also love to hear the answer to this, especially having moved to a new city after school where I didn't know anyone ahead of time. Grad school looks real tempting these days, at least once everything's back in person.