Loneliness was the unhappiness or depression an individual felt when they were alone, had no friends, or had nobody to talk to.
In 2259 in the alternate reality, Nyota Uhura asserted that Spock did not care about dying, arguing that he had not given a thought about their relationship with each other when he risked his life at the volcano on Nibiru. He, however, stated that it wasn't true, that he did not care, that he chosen simply not to feel anything. He explained that he had joined the consciousness of Christopher Pike as he was dying and experienced his feelings of anger, confusion, loneliness and fear, something he had experienced before upon the destruction of Vulcan. He told her his choice to experience those feelings was not a reflection of his not caring, that it was the opposite. (Star Trek Into Darkness)
In 2266, in her conversation with Captain James T. Kirk aboard the USS Enterprise, Eve McHuron rationalized the behavior of the male crewmembers, who were looking at her and following her with their eyes, as them being lonely. Then, Eve said she could understand loneliness and compared her state with that of Kirk. She thought he would understand loneliness more, saying, "... having to run a huge ship like this with so much responsibility every minute and having to be so careful with all your men looking up to you." (TOS: "Mudd's Women")
In 2364, Counselor Deanna Troi sensed terrible loneliness, along with pain and despair from the space vessel lifeforms enslaved by the Bandi of Farpoint Station. (TNG: "Encounter at Farpoint")
In 2365, when Lieutenant commander Data told Captain Jean-Luc Picard that he had responded to a message from the young girl Sarjenka, "Is anybody out there?," Picard empathized with his having done so, agreeing that there is a loneliness inherent in a whisper from the darkness. (TNG: "Pen Pals")
In 2373, after being briefly abducted by Marayna, Lieutenant Tuvok told her to consider that her feelings towards him were evidence of a deeper need, a more profound loneliness than she was willing to admit. He suggested she consider calling in a replacement for her task of monitoring the plasma fires within the nebula she was tasked with overseeing and she agreed that logically this might be the best thing for her to do. She asked him, however, to consider himself, if he would always be alone. Following this, he began teaching his crewmate Harry Kim the game of Kal-toh. (VOY: "Alter Ego")