How can I stay asleep? Even faraway trains wake me.

Use good sleep. Hygiene. If that isn't sufficient obtain medical evaluation. 1. Keep regular bed ; wakening time (includes weekends). Get up same time daily. 2. Make a regular, relaxing bedtime routine: warm bath or shower, aromatherapy, reading, or listening to gentle music. 3. Sleep in dark, quiet, cool room w comfortable mattress ; pillows. 4. Use bedroom only for sleep ; sex. Put work materials, computer.
Get checked out. You can have sleep problems from snoring, apnea, restless legs, poor sleep hygeine, anxiety/depression, napping during the day, night seizures, noises in the neighborhood waking you up, bed bugs, waking up to use the bathroom, acid reflux, allergies, or any number of things. Get checked out if fixing these don't help. Try ear plugs.