If depression is a factor, that is something you will have to work with to get better - I'm not sure from what you've posted if that is the case.
But I do think that people can feel less lonely if they look outside of themselves more. I mean, you have to look at/into yourself to a certain extent, to work on being content with yourself and your own company, and accepting yourself but also working on your flaws. However, being self-centered (harsh word I know) can make loneliness feel worse. I've been there, we've all been there. I was talking with one of my best friends last night who is a very selfless and giving person - she has had another bout of depression lately and said that she found herself slipping into "me me me" syndrome again. And that's not really the type of person she is. I've had episodes of at least borderline depression myself and at such times it is so hard to look outside of yourself. Your pain fills the whole world. But I tend to think that people who consistently feel lonely and isolated tend to be looking mainly at what they can get from other people, and not thinking about what they might be able to do for someone else. It's amazing how much better you can feel - even though it will not make all the problems go away - if you manage to do something good for another person or bring something into their life.