Internet has returned to Somalia after an outage of more than three weeks that cost the Horn of Africa nation the equivalent of $10m a day.

The country has restored its internet connection after repairing a severed undersea cable that was accidentally hit by a ship, a telecoms official said on Monday.

"The internet is now back, and clients are using it," said Adnan Ali, the media director for Hormuud Telecom, the country's top operator.

University studies were disrupted, and businesses had to close or improvise to remain open during the shutdown.

The lack of internet service also stranded patients who were seeking medical attention abroad as they couldn not access online paperwork.

A Somali Optical Networks (SOON) technician checks a satellite dish at their headquarters in Mogadishu Somalia. [Feisal Omar/Reuters]

Information Minister Abdirahman Omar Osman apologised to citizens on Tuesday for the outage, which hit all landline and mobile users apart from those with access to private satellite connections, and called for them to have backup plans.

"We urge internet companies to have a backup so that people do not suffer another outage in the future," he told Reuters.

Somalia's economy is picking up slowly after the army and an African Union peacekeeping force helped drive the al-Shabab group out of Mogadishu and other strongholds.

SEE MORE: Rebuilding Somalia

Al-Shabab wants to topple the Western-backed government and rule the country according to its strict interpretation of Islamic law.

Nur Bile, a police officer, said the number of reported attacks by al-Shabab had dropped during the outage, accusing the group of using the web to publicise its attacks and spread its ideology.

"There were almost no blasts in Mogadishu during the outage. Al-Shabab launches the attacks and the media spreads the news on the internet," Bile said.

Residents said the resumption of internet access was welcome news.

"I have the chance to communicate with my lost friends and relatives," said 25-year old Aden Ismail.

Source: News agencies