Loneliness usually comes when you have developed a need for others. I know many will agree with this, because when you have spent your life living for others, depending on people to validate you, make you feel better about you, chasing friends and friendships, always needing people around to make you feel wanted or needed, then when you are suddenly alone, you feel very lonely. But if you suffer with any of these issues, loneliness is what you need! Not forever, but at least for a season. You see, JESUS wants to be that friend you are searching for. Don’t you know that God put a need for himself in your life? Your purpose lies in him, so you must know him to know YOU! Your reason for being lies in him, so you must know him to know why YOU are YOU! And when you spend your life chasing friends or using people to find yourself, all you end up doing is having a bunch of one sided relationships, or failed relationships because you are searching for answers in the wrong places. And loneliness becomes a thorn to you even though being alone can be GOOD for you. When I was single, I realized that everytime I felt the pressure of loneliness, it was GOD calling me closer to Him. I would never trade those years of being a single woman where I poured out to God for hours. It was such a stretching period for me as God removed all of those things I placed my comfort in.
God loves you like crazy. Trust Him.