The Coast Guard had to free two tugboats stranded in the icy Hudson River this week.

“As the days stay cold, the ice is building up and getting thicker, and some of the smaller boats aren’t built for it,” Petty Officer Steve Strohmaier told The Post on Tuesday.

The Coast Guard’s Penobscot Bay, a 140-foot ice-breaking ship, freed the Brooklyn — a tug en route from New York City to Albany — Sunday evening.

The ship also assisted the Stephanie Dann on Tuesday morning after the tug sent out an SOS the night before that its engine had failed near Newburgh.

Stohmaier said the Coast Guard’s ship circled the stuck tugs to break the ice.

The Coast Guard is warning smaller boats to use caution while navigating the freezing Hudson.