This problem occurs particularly after the engine has been running due to the pressure relief valve located at the back of the pump inside. It is activated by a small spring and a metal cone which in time weakens and do not allow pressure to be relieved.
As the pump is driven by a permanently excited electric motor (when the engine is running) the pressure is reduced. After stopping, the fuel reservoir maintains pressure in the system to facilitate starting and with this pressure if the valve is stuck it develops an inner leak.
When this happens, if you tap the pump firmly it releases the pressure valve and the engine starts again. When the tapping affair becomes more frequent, it is time to replace the pump.
However, Mercedes have realized this and they provide a Check Valve which can be installed by replacing the existing hollow screw to the pipe connection to the pump, effectively providing a secondary pressure relief valve and avoiding having to buy a new pump. ( $7.50 for the Check Valve).
Deltacom ~ Absit Iniuria Verbis