Likely the fuel pump itself.
Bad relay unlikely to be helped by whacking on the pump cover.
Seen the same failure mode twice now on 2 different 300Es.
Whack on the pump, and it starts. Goes a while, sometimes a long while, sometimes not, randomly stops, whack it again....
gets you home eventually...
Suggest an OEM Bosch pump. I made the mistake of buying a slightly cheaper (and available on a Sunday) pump from AutoZone.
Works ok, but fits poorly, and it's much louder.
Best of luck.
1986 300E 5-Speed 240k mi.