Railway guns (like their seagoing analogues, battleships) have been rendered obsolete by advances in technology. Their large size and limited mobility make them vulnerable to attack, and similar payloads can be delivered by aircraft, rocket, or missile.
The idea of railway guns appears to have been first suggested in the 1860s by a Mr Anderson, who published a pamphlet in the United Kingdom titled National Defence in which he proposed a plan of ironclad railway carriages. A Russian, Lebedew, claimed to have first invented the idea in 1860 when he is reported to have mounted a mortar on a railway car.
The first railway gun used in combat was a banded 32-pounder Brooke naval rifle mounted on a flat car and shielded by a sloping casemate of railroad iron. On 29 June 1862, Robert E. Lee had the gun pushed by a locomotive over the Richmond and York River line (later part of the Southern Railway) and used at the Battle of Savage's Station to interfere with General George McClellan's plans for siege operations against Richmond during the Union advance up the peninsula.
In France, Lt. Col Peigné is often credited with designing the first railway gun in 1883. Commandant Mougin is credited with putting guns on railcars in 1870. The French arms maker, Schneider offered a number of models in the late 1880s and produced a 120 mm (4.7 in) gun intended for coastal defense, selling some to the Danish government in the 1890s.
The outbreak of the First World War caught the French with a shortage of heavy field artillery. In compensation, large numbers of large static coastal defense guns and naval guns were moved to the front, but these were typically unsuitable for field use and required some kind of mounting. The railway gun provided the obvious solution. By 1916, both sides were deploying railway guns.
The Second World War saw the final use of the railway gun, with the massive 80 cm (31 in) Schwerer Gustav gun, the largest artillery piece to be used in combat, deployed by Germany. The rise of the aeroplane effectively ended the usefulness of the railway gun. Similar to stationary battleships, they were massive, expensive, and, in the correct conditions, easily destroyed from the air.