On 25 October last year, Arron Doyle, of no fixed abode, entered the flat in Stoke Road in the early hours of the morning making threats, following an incident which began in the street outside.
The 39-year-old caused damage to doors in the process, before he was arrested by police a short while later.
He pleaded guilty to attempted robbery at Portsmouth Crown Court on 5 August this year.
He appeared at the same court where he was handed his four year prison sentence.