An Indonesian ferry carrying more than 800 people that had run aground was dislodged on Thursday and taken safely to dock at a nearby port, officials said.

KM Sirimau, carrying 784 passengers and 55 crew members, became stuck on Tuesday in shallow waters in East Nusa Tenggara province.

Efforts to free the boat succeeded and it was dislodged at noon after a tugboat sent by state-owned shipping company PT Pelni arrived to help, the head of local naval base Dwi Yoga told AFP.

The ferry docked in Lewoleba port on the island of Lembata for checks two hours after it was freed, local search and rescue chief Putu Sudayana said.

"All passengers are in good health," he told AFP.

Once the ferry was dislodged, relieved and tired passengers erupted in cheers, passenger Itha Tating said.

"We all shouted in joy when we found out the boat was free, the passengers and crew all started to clap happily," Tating told AFP by phone.

KM Sirimau, with 784 passengers and 55 crew members on board, was dislodged from shallow waters KM Sirimau, with 784 passengers and 55 crew members on board, was dislodged from shallow waters Photo: AFP / ATAGORAN

The ship will later leave the port to continue its journey to the town of Maumere on the island of Flores, the final destination of most passengers.

Passengers became worried after being stuck on the boat for two days, Tating said, with one woman panicking because she ran out of milk formula for her five-month-old baby.

"The waves were very strong this morning. I got scared and very dizzy from seasickness," Tating said, adding that she would not travel on ferries soon because she is still traumatised.

The military boarded the ship on Thursday morning to distribute water and snacks to the passengers, including children and the elderly.

Rescuers waited for the tide to rise before they towed the ferry, Yoga added.

Marine accidents are common in Indonesia, an archipelago of more than 17,000 islands, where people rely on ferries and other boats to travel despite poor safety standards.

In 2018, about 160 people drowned when a ferry sank into the depths of one of the world's deepest lakes on Sumatra island.