A Utah man got a rude awakening when he woke up trapped inside a 12-inch drainage pipe underneath a busy overpass, remaining stuck for hours until his rescue, authorities said.

The unidentified 40-year-old man had been trapped in the confined space for about four hours before he could find help, the Salt Lake City Fire Department said in a tweet Saturday.

OREGON WOMAN RESCUED FROM SEPTIC TANK AFTER BEING TRAPPED IN RAW SEWAGE FOR DAYS, OFFICIALS SAY

Passersby and others in the area heard the man's screams and called emergency responders, FOX13 Salt Lake City reported.

“He’d gone to sleep, either in the pipe or near the pipe, and slid down into it while he was sleeping,” Captain Adam Davies with the Salt Lake City Fire Department told the station. “When he woke up and was trapped in the pipe, he was screaming for help."

Davies said the man had become wedged about four feet down the 12-inch pipe, explaining that simply pulling him out by rope was impossible.

“We tried lowering a rope to him, [but] he couldn’t hold on to it,” Davies told FOX13. “We had to do some cutting on the pipe. Our heavy rescue team responded and they set up a pulley system to drag him out of it.”

CLICK HERE FOR THE FOX NEWS APP

The man appeared dehydrated with no significant injuries and was taken to a hospital as a precaution, fire officials told the station.

“It is rare to have a live rescue in a confined space like that,” Davies said, noting that reduced oxygen content and toxic gases usually kill those trapped in such places. “Any day you have a live rescue is a good day in the fire service.”