Red lights are associated with Port and Green for Starboard in maratime use. Vessels at sea do not actually have any 'right of way' - but if two ships on courses that intersect. The rule is that the ship on the left must give way. The stand on vessel sees the green light on the starboard (right) side of the ship on the left. The give way vessel sees the red light on the port side of the stand on vessel. The helmsman gives way to a red light by either turning away and showing a stern light, or by going around the stern of the stand on vessel.
This was likely the beginning of the convention for traffic lights that use red to mean stop and green to mean proceed with caution - rather than go. The use of maritime signals were adopted by the early railways in Britain, but with coloured flags because the first trains were rather slow.
They also adopted hand signals - Holding an arm out horizontal signals all right; proceed. Holding an arm vertical above the head means caution, slow. Both arms held above the head means stop. Semaphores - optical telegraphs were introduced by Claude Chappe (1763-1805) and his four brothers in revolutionary France, was adopted by many of the early Railways in England.
On the Liverpool and Manchester Railway, a white lamp moved up and down was a signal to stop, and was a signal of Caution, if moved from side to side. A succession of short sounds of the whistle was the signal to apply brakes.
They then introduced a number of fixed signals - vanes. The most common form of early railway fixed signals, consisted of a flat shape rotating about an axis, so that either the shape is presented full to the train, or its edge.
It was found that neither the shape nor the colour of a vane could be identified at a great distance under outdoor conditions, but at short distances vanes were quite practical.
These early vanes used shape not colour, and a lamp was used to display at night. They soon discovered that it was better to use the light of the lamp, rather than to illuminate the vane.
The signal invented by Woods was first used on the Livrepool and Manchester in 1834, but without the vane, as a support for the lamp. The vane was added around 1838.
Red flags were used as te sinal for stop, Green for caution and white for all clear. Note that blue is the colour of Caution in America. Until the introduction of British signals in the 1870's, this was quite typical. In the shade, red and blue squares both look like black, and would have been difficult to tell apart.
The semaphore was a day signal (as, of course were vane signals as well). By night, the aspects were presented by coloured lights of lamps. The colours were produced by moving coloured glasses in front of a light. We'll call the moving frame a spectacle, though it more commonly has three, or only one, apertures or roundels. Fortunately, coloured lights are easily perceived and recognized in darkness, so that even an ordinary oil lamp gives sufficent light. The perception of colour is not a simple thing, and colours are susceptible to modification by atmospheric conditions and the state of the eye. This was recognized quite early, together with the effects of anomalous colour vision ("colour blindness"). The intensities available with oil lamps are not sufficient for good daytime visibility (except in tunnels).
Brunel, on the Great Western Railway, designed excellent vane signals that displayed different shapes, so that colour played a subsidiary role. However, the whole signals were painted bright red for visibility, against the sky background. Green is a very bad colour for painting any signal; it is much less visible as a surface than as a light.
The combined Semaphore signal and lamps were patented in the 1840s by the American inventor John James Stevens, and soon became the most widely-used form of mechanical signal, although they are now decreasing in number. The semaphore arm consists of two parts: A blade or vane or arm which pivots at different angles, and a spectacle holding colored lenses which move in front of a lamp in order to provide indications at night.
Brunel may well have seen them on his visit to the United States, and imported them as station signals. The colours of the night aspects is a subject of some complexity. Even in the early days, a good red glass was available, and red and white (clear) were the colours used in signalling. In January 1841, faced with Parliamentary investigation and possible legislation, railway managers met at the Queen's Hotel, Birmingham (later the Curzon Street station, and still standing) to discuss safety issues. Henry Booth of the Liverpool and Manchester was the driving force at this meeting, and contributed the results of 10 year's experience on that line. The recommendations were essentially the practice of the Liverpool and Manchester Railway. Hand signals were standardized, and the signal colours of red, green and white were adopted. Blue signals stopped a train for traffic, and black flags were used by track workers. Red indicated Danger, White indicated Safety, and Green indicated Caution, Go Slowly. Green was introduced by this conference, and became generally adopted for Caution in all countries. As we have already mentioned, blue was used instead in America, though the adoption of green was soon noted. Green competed with blue, but was did not completely replace it until after British signals were imported in the 1870's.
On 10 December 1868, the first traffic lights were installed outside the Houses of Parliament in London, by the railway engineer J.P. Knight. They resembled railway signals of the time, with semaphore arms and red and green gas lamps for night use. The gas lantern was turned with a lever at its base so that the appropriate light faced traffic. Unfortunately, it exploded on 2 January 1869, injuring the policeman who was operating it.
The modern electric traffic light is an American invention. As early as 1912 in Salt Lake City, Utah, policeman Lester Wire invented the first red-green electric traffic lights. On 5 August 1914, the American Traffic Signal Company installed a traffic signal system on the corner of 105th Street and Euclid Avenue in Cleveland, Ohio.