Yes, it can be lonely.
That's why you need to have a life outside of work, especially if you work from home.
And if you don't like working from home, you can work from places where you can meet people :)

It mostly depends on the team, because the more you communicate with the team, the less lonely you feel.
But from the personal level, it's important to have human connections. I usually prefer working from public places such as shared working places of coffee shops for a few hours. If you need silence, there are also Public Libraries.

I find that having a routine that works for you is what's most important. If you long for more social contact, seek that out. You have the flexibility so you can schedule social activities in between work. Eg a group session at your gym, meet with a friend in the city for lunch, ...