Reputably the 'longest train in the world', The Iron Ore train in Mauritania can be up to 2.5km long.
The train transports iron ore across Mauritanis but also has one passenger wagon where you can pay to ride first or second class, even though both of them are VERY basic!
If you think you can brave traveling in an outdoor wagon with hundreds of other frantic men, you may find a free place on top of the wagons that transport the Iron ore. It is not very safe though and not recommended.