The assault on the coastal district of Dhubab, just 30 kilometres north of the Bab al-Madab strait where the busy shipping lane enters the Arabian Sea, came after the government sent reinforcements from its headquarters in Aden.
The government and its allies in a Saudi-led coalition recaptured the strait in October 2015.
But the rebels still control nearly all Yemen's Red Sea coast to the north, posing what the coalition says is a threat to international shipping.
The loyalist offensive failed to dislodge the rebels from their positions as they put up fierce resistance, leaving many wounded on both sides, the commander said.
The Yemeni conflict has killed more than 7,000 people since the coalition's military intervention began in March 2015, according to the United Nations.