Almost half of prisoners leaving Cardiff Prison are homeless, inspection reports have warned.
Concerns were raised about the situation at HMP Cardiff, with inspectors citing a ''well-established link'' between homelessness and the risk of re-offending.
Peter Clarke, chief inspector of prisons, said an ''extremely high figure'' of 47% of inmates released from the prison during the six-month period before he visited in July had no accommodation to go to.
Of inmates released in the six-month period before July had no accommodation to go to.
The category B prison releases more than 200 men each month, and probation teams failed to follow up with inmates adequately afterwards, the report found.
''The well-established correlation between homelessness in these circumstances and the risk of reoffending is well known.'' Mr Clarke said.
''This was a problem that is clearly beyond the ability of the prison service to address on its own.''
He told the Prison and Probation Service and the Welsh Government to ''work together to find solutions to this very serious problem.''
Despite the July inspection being ''enormously encouraging'', the prison was ''not immune to wider social problems'', the report said, warning that some 65% of arrivals reported having mental health problems.
Of new inmates reported having mental health problems.
More than half of new prisoners reported drug problems, a third said they had problems with alcohol - with more than 350 needing treatment - and self-harm had risen threefold.
The prison, which holds more than 700 men, was described by inspectors as having bucked the national trend in rising levels of violence.
''HMP Cardiff disproves the cliches about inner-city Victorian prisons inevitably being places of squalor, violence and despair.'' Mr Clarke said.
''The improvements since the last inspection were incredibly encouraging to see, and were testimony to the hard work that had brought them about.''
Amy Rees, director general of the Prison and Probation Service in Wales, said the body was ''working closely'' with the Welsh Government to address the problem of homelessness on release adding: ''The prison is in much better shape than it was a few years ago.''
In July, the Welsh Government announced £273,000 to support men leaving the prison.
Tackling homelessness is a priority. We have put a number of measures in place to prevent people becoming homeless, including Housing First, which specifically supports prison leavers, helping to break the cycle of prison and homelessness.
The Ministry of Justice said that stable accommodation for prison leavers is ''a crucial factor in cutting reoffending.''
We are spending an extra £22m a year helping offenders stay off the streets and have placed a new duty on prison governors to alert the council if someone is leaving their jail at risk of homelessness. We're also helping vulnerable former prisoners to find stable accommodation through a £6m pilot as part of the Government's £100m rough sleeping strategy.