Mr McDonnell told train bosses to wake up and understand the anger felt by staff.
Pressed on whether a “winter of discontent” could be looming on the railways, he said: “We will see what industrial action takes place.
“I’m hoping for negotiated settlements. But don’t underestimate the depth of anger among rail workers.”
His words came as unions welcomed a pledge by Labour to transform workers’ rights, with special help for millions in the gig economy.
Mr McDonnell received a standing ovation from the TUC Congress in Manchester when he laid out a series of measures aimed at “tipping the balance” from employers to workers.
He also said a Labour government would ban zero-hours contracts, repeal the Trade Union Act and clamp down on bogus self-employment.