A suicide bomber rammed his car at a checkpoint near the Port of Mogadishu, causing a loud explosion and falling metal debris which sent workers running helter-skelter.
Police had opened fire on his car just as it sped toward a metal barrier protecting a headquarters linked to the port.
In the outskirts of Baidoa, some 243km west of Somali capital, four people were killed around the same time after a remote control device was detonated inside a restaurant.
The eatery was reportedly filled with customers eating breakfast when the explosion rocked the restaurant.
The militant group al-Shabaab has not yet claimed responsibility for both attacks but last week it said its insurgents carried out an attack at an army base in Mogadishu which killed two people.
The attacker who had rigged with explosives blew himself after infiltrating a queue of recruits at a training camp run by the Turkish military.
The blast went off before sentries could stop him at the entrance to the academy commonly called Turksom which is responsible for training recruits for the Somali army.
The Turkish military has been running the academy since 2017.
Although al-Shabaab fighters have been largely driven from most urban areas around Somalia, they have retained a capacity to launch attacks on targets in the capital.