The idea of being lonely stems from the concept of being alone. If you are without people around you or with people you do not particularly connect with, you are alone. If you are upset about being alone, then you would be considered lonely. Fairly simple, yes? Not quite.
See, this concept does not take into account the fact that our own thoughts and internal monologue do count as a form of personal connection. Everyone has a relationship with themselves as they do with any other person, the only difference is that this connection is less physical and more abstract. This tie with ourselves, however, functions almost identically to relationships with other people. This implies that, as you can like or dislike being around certain people, you can also like or dislike being around yourself.
So now, we must ask ourselves this: Have I ever felt lonely, even in the presence of others? If you said yes, then you would probably go on to justify that you were not around friends or were with people you did not particularly enjoy being around. You being in such a situation caused a feeling of sorrow towards your social situation. In other words, you were lonely.
Now, who is to say you cannot feel such a thing with yourself? Who is to say you do not consider yourself a friend or someone you enjoy being around? The reality of it is that people dislike being left to themselves for a multitude of reasons. Should you feel upset at the fact that you are with only yourself, then you could be considered lonely.
Usually when we consider ourselves lonely around others, we are able and willing to understand that we are not around favored company or maybe even around unpleasant people. However, when we are lonely around ourselves, we do not even consider the notion that we may still be in unpleasant company. It does not even cross our minds that our relationship with ourselves may not be as good as we originally thought it to be. In all honesty, the exchange with the self is one of the most important exchanges we can have, and yet it is one of the most ignored. Many simply assume they have good relations with themselves. Those who do acknowledge how bad the connection is are typically those with intense issues with self-loathing, anxiety or depression. Other than that, we have not allowed there be room for one to have a less than ideal relations with themselves without having cleanly labelled mental issues and this is incredibly ridiculous.
No matter how much you may be with friends, family or even strangers, you are always with yourself. No matter where you are or the time of day, you are always subjected to your own opinions and thoughts on yourself. It is an everlasting presence and ongoing experience, but it is ignored as if it were something too minuscule to bother with.
The truth is that your relationship with yourself is a mirror for how much you may like or dislike yourself. As you can mistreat others, you can mistreat yourself and it is vital to become more aware of when you do so. Having a good relationship with yourself can not only improve mental health but also improve your functionality.
It becomes easier to forgive yourself for mistakes. You are more able and willing to handle those difficult realizations. You even raise your ability to accept your own flaws and improve upon them. While this can be done with a bad exchange with yourself, it is infinitely harder and much more painful. In a bad self-relationship, you are driven by hate and spite and are very willing to beat yourself up over the smallest things. However, in a good self-relationship, you are driven simply by your own desire and what you wish to become. You turn yourself from foe to friend and begin to properly work with your own limitations and abilities.