'Solitude' and 'loneliness' are two very different concepts: while the first simply signifies a state, the other signifies the feeling of lack in that state.
How can transmute the crushing agony of loneliness into the serenity of solitude?
The feeling of loneliness stems from experiencing/being only a small part of Who We Are - namely, our human selves.
The experience of being disconnected creates the feeling/vision of nothingness crushing down on the core of being. This is a primal force which cannot be evaded.
Loneliness/solitude plays a major part in interpersonal relationships as well. Interaction with people does not alleviate loneliness, although it may push the awareness thereof below the threshold of consciousness.
Also, loneliness can be even more accentuated if you are amongst people. The contrast may bring forth an acute awareness of the ever-present, looming nothingness.
(The priests and monks were on to something with their ideas of celibacy and enforced solitude; it is a pity their implementations were so poor.)
The choices and decisions we make define our unique human selves. This process requires certain differentiation which we often misconstrue as emotional distance.
The strength we can achieve as individuals is by accepting the crushing nothingness. This washes away the distances which cause the pain of loneliness.
A person serene in solitude is Whole.