Make, model, and year are crucial for this. In Honda vehicles, especially those more than ten year old or so, the relays themselves become intermittent. In many GM vehicles the passive anti-theft system kills the fuel pump relay. In my Nissan 300ZX it was because the ECU had gone insane and believed the engine was not running, even as it delivered spark and injector pulses. Ford vehicles can do that if the impact switch (safety switch) trips.
relay may be faulty, fuse may be burned out, or relay may be getting bad info -- CPU bad, clogged filter or other problem causing excess pressure, etc.
A plugged fuel filter or low fuel pressure.