Railways use a number of coloured flags. When used as wayside signals they usually use the following meanings (exact meanings are set by the individual railroad company):
red = stop
yellow = proceed with care
green or white = proceed.
a flag of any colour waved vigorously means stop
a blue flag on the side of a locomotive means that it should not be moved because someone is working on it (or on the train attached to it). A blue flag on a track means that nothing on that track should be moved. The flag can only be removed by the person or group that placed it. In the railway dominated steel industry this principle of "blue flag and tag" was extended to all operations at Bethlehem Steel, Lackawanna, NY. If a man went inside a large machine or worked on an electrical circuit for example, his blue flag and tag was sacrosanct.The "Lock Out/Tag Out" practice is similar and now used in other industries to comply with safety regulations.
At night, the flags are replaced with lanterns showing the same colours.
Flags displayed on the front of a moving locomotive are an acceptable replacement for classification lights and usually have the following meanings (exact meanings are set by the individual railroad company):
white = extra (not on the timetable)
green = another section following
red = last section
Additionally, a railroad brakeman will typically carry a red flag to make his or her hand signals more visible to the engineer. Railway signals are a development of railway flags.