The train, which carried cooking oil, slammed into passers-by who were walking beside the track when it derailed Monday. The cause of the derailment was not immediately known.
Residents of the sprawling Kibera slum in Nairobi, the capital, have extracted two bodies from wreckage as police looked on.
Train crashes and road accidents are frequent in Kenya where roads are poorly maintained and the government is accused of corruption.