An NYC Ferry boat carrying 27 people ran aground on a sandbar off the Rockaways on Wednesday evening — stranding it for hours in sub-freezing temperatures because the water is too shallow for a rescue, the US Coast Guard said.

“We’re waiting for either the tide to come up or the NYPD to come with its shallow draft boat,” a Coast Guard spokeswoman said.

No one was injured when the boat got stuck around 5:30 p.m. said Skye Ostreicher, a spokeswoman for ferry operator Hornblower.

The ferry didn’t sustain any apparent damage and wasn’t taking on any water, an FDNY spokesman said.

But the heat on the boat was turned off shortly before 8 p.m., passenger Jake Nicholson told The Post by cell phone.

Although officials initially opted against evacuating the stranded vessel, that plan changed sometime before 7:30 p.m., and officials were preparing to bring everyone to the NYC Ferry terminal at 108th Street and Beach Channel Drive, the FDNY said.

An FDNY Medical Emergency Response Vehicle, four ambulances, five fire trucks and dozens of emergency workers were stationed there.

Data posted on the MarineTraffic.com Web site identified the boat as the Flyer, and showed it stopped northwest of the Breezy Point Tip park shortly after 8 p.m.

The ferry departed from the Rockaway terminal at 5:15 en route to Wall Street’s Pier 11.

An overhead image posted on Twitter by Channel 7 Eyewitness News at 6:35 p.m. showed the ferry all but blacked out in the frigid, 22-degree darkness.

Four ambulances and five fire trucks were stationed at the NYC Ferry terminal at 108th Street and Beach Channel Drive, with emergency workers apparently awaiting the arrival of passengers.

The incident marked the second grounding of an NYC Ferry boat in recent weeks.

On Nov. 27, the Zelinksy was damaged when it smashed into a sunken pier near Wall Street’s Pier 11 while en route to the Rockaways.

That mishap occurred the same day The Post exclusively revealed that several Ferry boats had to be taken out of service and repaired after springing leaks.

The NYC Ferry service, operated by the Hornblower cruise company, was established by Mayor de Blasio and began operating earlier this year with $325 million in taxpayer subsidies.