An Upper West Side commuter was sent so far off the rails Friday when he missed his bus — that he hailed a cab, chased down the driver and pulled a gun on him, according to police and the rattled transit worker.

Tony Burnett, 28, turned into an uptown Mad Max when the M11 bus rumbling along Columbus Avenue passed him by at West 85th Street at around 7:50 a.m. according to police.

Of course, there was a good reason for this — there was no bus stop on the corner where Burnett was trying to catch one.

“As I’m approaching 85th Street, I saw a guy waving his hands,” the driver, Michael Haynes told The Post. “I continued on to 84th Street because I can’t just stop at every single corner to let people on.”

No matter to the crazed commuter, who allegedly ordered the cabbie to cut off Haynes a couple blocks away.

He then hopped out of the car and climbed onto the bus, according to cops.

“Why didn’t you stop for me?” Burnett growled at Haynes, according to police — before allegedly pulling a loaded .38 revolver out of his pants.

As he allegedly flashed the gun, the seething commuter tore into Haynes with a swear-laced racist rant, Haynes told The Post.

“He gets out and starts cursing, yelling n-word like crazy. Just basically what he was doing was in a threatening manner,” Haynes recalled. “He said, ‘You don’t know who you messing with.’”

He continued, “When he pulled the gun, I felt that this guy doesn’t need to be out on the street like that…Someone could die with him out here.”

Burnett — who is known as a “troublesome passenger” and fare jumper— bolted when he saw a crowd start to form, allegedly leaving the gun behind, according to Haynes and police. Cops later found it in a bag and arrested him.

Burnett was charged with reckless endangerment, felony criminal possession of a weapon for the illegal firearm and menacing, police said.

At the police station, Burnett allegedly acted “erratically” and was brought to Roosevelt Hospital for a psychiatric evaluation, police said.

MTA officials cheered cops for their quick-thinking Friday.

“The MTA is grateful that the threat of an armed man menacing riders and the driver on this bus was ended without harm to anybody. We commend the NYPD for its swift action to locate the perpetrator blocks away, making a quick arrest,” the agency said in a statement

Burnett has an arrest history dating back to at least 2009 for assault and robbery, law enforcement sources said.

In June, he was arrested for theft of service for hopping the turnstile at a subway station.

Additional reporting by Natalie O’Neill and David Meyer