The invention relates to a bed, especially hospital bed safety rail (2), which is attached to a lengthwise (A-A) side of a bed (1). The safety rail comprises two end supports (3, 4) disposed at a distance from each other, and at least one rail section (5; 51, 52, 53, 54) disposed between the end supports (3, 4) substantially in a longitudinal direction of the bed. The end supports (3, 4) are mounted pivotally in engagement with the bed, such that the end supports are rotatable from a position inclined in the longitudinal direction of the bed to an upright position as the safety rail (2) is raised from a bottom position (B) to a top position (C), and respectively rotatable in an opposite direction as the safety rail is lowered from the top position to the bottom position. Thereby, the rail section (5; 51, 52, 53, 54) being retains, despite the rotating motion, its substantially horizontal orientation. According to the invention, the safety rail (2) further comprises a gas spring (6) disposed between the rail section (5; 51) and the end support (3).