By rethinking everything about yourself and your relationship to the World as a whole.

I live alone with a hermit-like lifestyle (even though i live in the middle of a big city) and so perhaps my advice may be of some use.

Read Philosophy, Read Psychology and orient your entire Worldview accordingly. This is very important; you cannot choose solitude while thinking and longing for external socializations/validations. Self-Denial and Self-Control are the key attitudes to practice. A complete framework/discipline like Patanjali Ashtanga Yoga is a good one to follow.

Keep Body Active, Maintain proper Diet and Sleep. Whenever you feel down/depressed get out and walk (or do any physical activity). Become aware of what in the environment triggers your "loneliness" and consciously move away from it.

When you go to the grocery store/coffee shop/restaurant/etc. converse/joke/laugh with the employees/customers there since that is your much needed essential "socialization" fix. Understand how the self uses social-surrogates to satisfy its social needs eg. social media.

The key idea is that you limit socialization/interaction to the absolute essentials i.e. to that which is impelled by nature.

Also Mind and Body are one and so problems can be solved by approaching them via both avenues. This is why motion/exercise is so good for the mind.

Cultivate total Zen-like "mindfulness in the present" so that your mind forgets the self and is fully occupied in any activity you are engaged in which could be as mundane as house-cleaning/dishwashing/etc.

Live in the present, with your consciousness externalized momentarily but without any effort; when the mind stops linking itself to the past and to the future, it becomes no-­mind. If from moment to moment your mind dwells on what is and drops it effortlessly at once [just before moving on to something else], the mind becomes no-­mind, full of purity.

-- Yoga Vasistha

PS: Some of my previous comments which are relevant here - https://news.ycombinator.com/item?id=40978488 , https://news.ycombinator.com/item?id=44987175 , https://news.ycombinator.com/item?id=41538322 , https://news.ycombinator.com/item?id=29777785 , https://news.ycombinator.com/item?id=32918811