A police spokesman in Lucknow, capital of Uttar Pradesh state, said 500 people were knocked off the roof of the packed train as it travelled overnight from Allahabad city to an army recruitment centre.
"The accident occurred in the dark when branches hit these people squatting on the roofs of the carriages and they fell off on both sides of the moving train," said police officer Manish Singh.
Thousands of people are killed every year in accidents involving India's British-era trains. Passengers who cannot get into over-crowded carriages or do not have tickets often ride on the trains' roofs.
The state-run utility, which carries some 13 million people daily, has said it is investing tens of millions of dollars to modernise the network.