Sean Gorman, now 18, attacked a 25-year-old man at the property on Upper Gilmore Place in the early hours of Thursday May 3.
Gorman had been visiting the hostel when the victim, who was resident there, called at his room due to the level of noise.
Gorman made threats and racially abused the victim before stabbing him and leaving the property. He was traced a short time later in Duff Street and arrested.
The victim suffered serious injuries, which required extensive hospital treatment.
At the High Court in Edinburgh on Thursday July 19, Gorman admitted racially-aggravated attempted murder, as well as causing racially-aggravated alarm to a woman within the hostel.
Gorman has now received a sentence of eight years in prison.
Detective Chief Inspector Paul Grainger of Edinburgh Division’s CID said: “Gorman used appalling racist language before perpetrating significant violence against the victim, who was left fighting for his life.
“I cannot condemn the circumstances of this case strongly enough. Edinburgh thrives on diversity and Gorman’s actions do not in any way reflect the values of our city.
“Significant support has been shown across the capital for the victim and his family, which is far more representative of the strength of inclusivity across our communities.
“We welcome a custodial sentence and our thoughts remain with the victim and his family as they continue to try and move forward with their lives.”