Railways use a number of colored 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 or blue = proceed.
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.
At night, the flags are replaced with lanterns showing the same colors.
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.