rail (n.1) Look up rail at Dictionary.com
"horizontal bar passing from one post or support to another," c. 1300, from Old French reille "bolt, bar," from Vulgar Latin *regla, from Latin regula "straight stick," diminutive form related to regere "to straighten, guide" (see regal). Used figuratively for thinness from 1872. To be off the rails in a figurative sense is from 1848, an image from the railroads. In U.S. use, "A piece of timber, cleft, hewed, or sawed, inserted in upright posts for fencing" [Webster, 1830].
rail (n.2) Look up rail at Dictionary.com
"small wading bird," mid-15c., from Old French raale (13c.), related to râler "to rattle," of unknown origin, perhaps imitative of its cry.
rail (v.1) Look up rail at Dictionary.com
"complain," mid-15c., from Middle French railler "to tease or joke" (15c.), perhaps from Old Provençal ralhar "scoff, to chat, to joke," from Vulgar Latin *ragulare "to bray" (source also of Italian ragghiare "to bray"), from Late Latin ragere "to roar," probably of imitative origin. See rally (v.2). Related: Railed; railing.
rail (v.2) Look up rail at Dictionary.com
"fence in with rails," late 14c., from rail (n.1). Related: Railed; railing.