In a world with over 7 billion people clearly there are no shortage of people to engage with. Loneliness comes from feeling like no one "gets you" or understands you.
More often than not it's a crisis of the ego.
We either think we're smarter than everyone around us and therefore they are unable to relate on "our level" or we believe everyone else in the world has their act together and we are bottom dwelling losers.
People who feel good about themselves never feel lonely even if they are alone! People who avoid becoming "self-centered" rarely feel disconnected from the world. If one takes (an interest in others) and things around them people tend to be attracted to them. We have the option of choosing our thoughts and placing our focus wherever we choose. If you know yourself well then you also know what music puts you in a good mood, food, drink, movies, books, locations, activities, and people who seem to help pull you out of a funk.
The act of cutting ourselves off from the rest of the world often leads to feelings of loneliness and isolation. Sometimes it helps to find like minded groups of people that are on the same path as yourself.
The only real cure for depression is taking action.