Harbors. And any city that connects via Railroads to a city with Harbors.
So if your Capital is not on the coast you need to connect one coastal city with railroads to the capital, so that all cities with harbor get the bonus. And non-coastal cities on the other continent likewise need to have a railroad to a city with a harbor.
What I totally liked when starting my first CiV game (coming from CIV BTS) was how they changed roads and railroads. I liked that I didn't have to connect resources with roads, and then got shocked on how expensive roads are early in the game.
Took a while until I learned the citysize<->tiles to connect + 1 one rule of thumb. Basically the idea is that if a city is 6 tiles away, it should grow to size 7 before you connect it to make a profit on the trade route. Now there may be other reasons for why you want to connect a city (troop movement is a major one) but when I was a n00b, I devoted time and the cost of workers connecting cities of size 2 thinking it was a good thing. My Bad!
And I also like that railroads are no longer a tech you beeline. Will be researched eventually, but once you get the tech you don't go all railroading your entire empire like you kinda had to do in CiV. Typically when you get railroads, you still wanna spend your money on other stuff and have to build your rails over time with care to not bust your economy.