The story
A first local railway was constructed in 1895 by the Damaraland Guano Company for commercial purposes. The first public railway, and the core of the present system, was constructed by the German colonial government. The 383 km connection between Swakopmund and Windhoek was inaugurated on June 19, 1902. The German colonial railway was taken over by the Railways of South Africa after World War I, and linked into the network of South Africa. After the independence of Namibia, TransNamib took control of the national rail network.
From Wikipedia’s article on TransNamib, shared under CC BY-SA 4.0.3