Alternatively, if you measure "the distance travelled along the rail, without double counting" then the longest journey is probably equal to the total length of the installed rail network in Eurasia, which is an interesting statistic and a challenging optimisation problem, but hard to consider as a single journey.
[0] https://en.wikipedia.org/wiki/Circle_Line
[1] https://en.wikipedia.org/wiki/List_of_countries_by_rail_tran...
Ie, the longest track distance between any two places on Earth, subject to the constraint that there is no shorter train journey between those two points.
This seems to me to be a much more logical, and also more interesting, interpretation of the question than the one used in the article.