Dozens of Somali refugees have been killed off the coast of Hodeidah in Yemen after a helicopter attacked the boat they were travelling in, according to the International Organization for Migration.

Joel Millman, spokesman for the Geneva-based agency, told the AFP news agency that 42 bodies had been "recovered", after earlier reports on Friday had put the fatalities at more than 30.

Mohamed al-Alay, a local coastguard officer in the Houthi-controlled Hodeidah area, told the Reuters news agency that the refugees were on their way from Yemen to Sudan when they were attacked late on Thursday by an Apache helicopter near the Bab al-Mandeb Strait.

The refugees were reportedly carrying official UN refugee agency (UNHCR) documents.

A sailor who had been operating the boat, Ibrahim Ali Zeyad, said 80 refugees were rescued after the incident.

It was not immediately clear who had carried out the attack.

William Spindler, a spokesman for UNHCR, said many of those killed and wounded were registered refugees who had escaped conflict in Somalia.

"We are appalled by this attack on innocent civilians. These are people who have already suffered so much and risked their lives to flee Somalia," he said.

"They are people who ... tried to find security in Yemen but found the situation there becoming increasingly dangerous, with the conflict and the humanitarian crisis coming close to a famine. And now, trying to go somewhere else to look for safety and finding this tragic end."

Hodeidah, on the Red Sea, is controlled by Iran-allied Houthi fighters who in 2014 overran Yemen's capital Sanaa and forced the Saudi-backed government of President Abd-Rabbu Mansour Hadi to flee into exile.

An Arab coalition was assembled by Saudi Arabia in 2015 to fight the Houthis and troops loyal to former President Ali Abdullah Saleh who have fired missiles into neighbouring Saudi Arabia.

The Bab al-Mandeb is a strategic waterway at the foot of the Red Sea through which nearly four million barrels of oil are shipped daily to Europe, the US and Asia.