A wayward bullet, one of 50 that undercover detectives fired at Sean Bell and his friends, nearly hit a Port Authority cop a block away on patrol at a Queens elevated-train station, the officer and his partner testified yesterday.

“I ran for cover,” Officer John Cea said at the trial of three detectives charged in the Bell slaying.

“I was sprayed by some of the glass that had been shattered by the bullet.”

Cea said he was on patrol at 4:14 a.m. on Nov. 25, 2006 – walking along the elevated AirTrain platform near Liverpool Street in Jamaica – when he first heard gunshots.

“I remember hearing a pop, and a short time after, more shots in rapid succession,” Cea said during his testimony in Queens Supreme Court.

“I remember hitting the ground. I got down as low as I could.”

Cea said one of those bullets whizzed over his head, then “the window of the Air Train platform blew out.”

Detective Marc Cooper, who pulled the trigger four times and has been charged with reckless endangerment, fired the bullet that hit the Air Train station.