I see you're in the UK (it says below your avi, I'm not stalking lol

). I was homeless off and on for 4 years. There's usually multiple Homeless Hostels you can live in if you have tried? It's not like homeless
shelters where it's first-come-first-serve each night for a bed and you feel really unsafe. You get a bedroom (that locks for your safety and so people can't steel) there permanently. You do have to pay, but it's like £20-£35 per fortnight. It counts as a "fixed abode" too, so you can get government benefits, apply for jobs if you feel able etc. They sometimes offer either one or two (LARGE) free meals per day, too.
Those places really saved my ass many times.
I don't blame you at all for falling back into using. Being homeless is scary and awful and I wouldn't wish it on anyone. I ended up homeless in my late teens when my parents kicked me out (bulimia and alcohol) and I rapidly went from like a liter of vodka a day to a liter of vodka and 3 or 4 bottles of wine a day because I was anxious/lost/bored and found it impossible to sleep etc. I also ended up on IV heroin*. I think getting off the streets and finding a safe place to stay would be the first step, and a big step in the right direction.
*I was already on opioids as I had a legit script for Oxycodone that I kept insisting I needed more of until my doctor decided to stop increasing as he thought 200mg/day was already a lot for someone in their teens and weighing like 7 stone, and I found it so easy to buy online. Switched to heroin as it was so much cheaper and everyone around me in the homeless community was on either that or coke so I had extremely easy access.
I know this is hard to hear and not what you wanna hear, but the only way to stay sober is to cut off all ties with the addicts around you, including your friends (whether or not they are REAL friends or drug-friends). I did that several years back...it was hard and I felt very lonely and isolated at first, but I got up the courage to contact old, healthy-for-me, friends from high school and just said like I missed them, did they wanna meet up? And now we meet like once a month just to go for a meal and to the cinema or something.
I decided to finally learn Spanish and started going to classes and met people there, too.
It's really hard to get away from all those people around you, but it's 100% necessary to get and stay clean.
I wish you the best of luck!