After former striker Sean Hunter had put his new side ahead, Louie Gibson equalised to send the sides in level at the break.
Sam Clark and Dan Nimick netted before the hour mark to put Town in a commanding position and, though Railway pulled a goal back late on, Sam Barker found the bottom corner before time was up to seal local bragging rights.
Just two minutes after Aaron Haswell had gone close at the near post, Sean Hunter's pace got him in behind and, though Joe Wilton got to the ball first, his clearance cannoned off the Railway striker and rolled into the empty net.
Town then had two efforts for an equaliser cleared off the line within minutes of each other.
First Haswell received a pull back, skipped past his marker and shot low, but his goal bound effort was blocked by a defender on the line, then Sam Clark escaped Railway 'keeper Will Godbehere, but was denied by the recovering Railway number six.
Incredibly Town then saw two crosses hit the frame of the goal as Rob White's right wing cross clipped the post, then Amarri Dixon-Blair's effort from the other flank did the same!
Town continued to press and went close through Clark, who was denied by Godbehere and White, who flashed wide of the far post.
Just past the half hour mark Josh Falkingham's side grabbed an equaliser as Neil Patience's well hit free kick clattered the underside of the bar, before Gibson was first on the scene to convert the rebound.
Railway had chances to regain their lead late on in the half through Savory and Hunter, but the sides went in level.
Four minutes after the restart Clark latched onto a through ball and lofted over the advancing Godbehere to put Town ahead.
Town made it three on the hour mark as Nimick got his head to a near post cross and was able to diver the ball into the net.
Six minutes later Railway responded as Hunter's corner was emphatically volleyed past Wilton at the back post.
Despite Railway pushing men forward to try and find an equaliser, it was Town who claimed a late goal as Barker fired into the bottom corner in the 88th minute to seal the win.
Town U19s: Wilton, Perreira, Chippendale (Darville 72), Barker, Gibson, Nimick, White (Richardson 64), Patience, Clark, Haswell, Dixon-Blair (Little 83)
Subs not used: Widowson, Foster
Goals: Gibson 32, Clark 49, Nimick 60, Barker 88