The following is from chapter 10 of the second volume of Bilvavi Mishkan Evneh:
Let us imagine that a person is alone late at night. No one is home. He feels lonely. What does one do? He immediately tries to call someone. It’s hard to be alone. “It is not good for man to be alone.”
But the truth is that the real company for a person should be Hashem! Whenever you feel lonely, you should recognize this truth. Sure, it’s not always possible to act upon this awareness, but you must first attain the recognition of this truth, and when alone at home and feeling lonely, you should not rush to the phone to speak, but rather, stop and think: “Why did Hashem create in me this feeling of loneliness? Why did he cause me now to feel so lonely?”
After thinking, you will understand that loneliness is a tool for realizing that one cannot live here alone. The way to solve the problem of loneliness is not the one people superficially imagine. Hashem wants to bring one to the truth, so one will not feel lonely. How? By connecting to the Creator!
When one sits at home and feels lonely, he must first remember the first point, which is that this loneliness derives from the soul not feeling that Hashem is here.
He must collect his thoughts and say to himself, “I know that the truth is that Hashem brought me to this situation of loneliness so that I will connect with Him. I also know that I am not yet on that level, and I can’t do that yet, but Hashem wants me to get to that level. He is not allowing me to forget the truth. That is why He is constantly arousing in me the feeling of loneliness, so that I will be inspired and remember that the only way to fill the inner emptiness is through Hashem.
On the pasuk, “And Yaakov remained alone” (Bereishis 32:25), there is a well-known comment of Chazalthat this relates to the phrase, “And Hashem will be alone on that day” (Yeshayahu 2:11). That is to say, the “alone” of Yaakov Avinu must be joined to the “alone” of Hashem. The pasuk likewise states, “Behold a nation that dwells alone and is not counted among the nations” (Bemidbar 23:9). The “alone” of a Jew must connect to the “alone” of the Creator, and then there is real companionship.
Thanks to A Simple Jew for suggesting I post this.