"bar," early 14c., from Old French reille, 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. Technically, railings (late 15c.) are horizontal, palings are vertical.
"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" (cf. Italian ragghiare "to bray"), from Late Latin ragere "to roar," probably of imitative origin. See rally (v.2). Related: Railed; railing.