A man in Pennsylvania was living a nightmare early Monday after he fell asleep inside a dumpster and woke up screaming inside a garbage truck, officials said.

The unidentified man told police he had gotten separated from a friend the night before and needed a place to go to sleep, choosing the nearby dumpster, Pittsburgh Public Safety Officer Cara Cruz said in a statement.

UTAH MAN RESCUED FROM 12-INCH DRAINAGE PIP AFTER FALLING ASLEEP, BECOMING TRAPPED FOR HOURS: OFFICIALS

A driver with Republic Services was emptying a garbage container into the back of his truck around 3:30 a.m. when he heard a man’s screams growing louder, Cruz said.

The Pittsburgh fire and police departments responded to a call of a man trapped inside a garbage truck early Monday, officials said. File (Republic Services)

The driver told police he left the truck and opened a sliding door in the rear when he discovered the man. Unable to get the man out himself, he called police for help.

CLICK HERE FOR THE FOX NEWS APP

Pittsburgh firefighters eventually pulled the unidentified man from the back of the truck, Cruz said.

The man was taken to the hospital with minor injuries to his face and knee.