Issue#

A service crashes, systemd restarts it a few times, then stops trying. After that, systemctl start fails right away and the service stays down:

sudo systemctl start myapp
Job for myapp.service failed because start of the service was attempted too often. See "systemctl status myapp.service" and "journalctl -xeu myapp.service" for details. To force a start use "systemctl reset-failed myapp.service" followed by "systemctl start myapp.service" again.

The journal shows:

systemd[1]: myapp.service: Scheduled restart job, restart counter is at 5. systemd[1]: myapp.service: Start request repeated too quickly. systemd[1]: myapp.service: Failed with result 'exit-code'. systemd[1]: Failed to start myapp.service - My App.

Cause#

systemd limits how often a unit can be started. By default it allows StartLimitBurst=5 starts within StartLimitIntervalSec=10s. With Restart=always or Restart=on-failure and the default RestartSec=100ms, a service that crashes on startup uses up those 5 attempts in under a second. systemd then marks the unit as failed and stops restarting it.

The start limit itself is not the real problem. The service is crashing, and the limit only stops the restart loop.

Solution#

  1. Find the real error. Look at the log lines from before the "repeated too quickly" message:
journalctl -u myapp.service -b --no-pager -n 50

Common causes are a bad config file, a missing environment variable, a port that is already in use, or wrong file permissions. Fix that first.

  1. Check the current restart settings and how many times the service has restarted:
systemctl show myapp.service -p Restart -p RestartUSec -p StartLimitBurst -p StartLimitIntervalUSec -p NRestarts
  1. Make the restarts slower so short failures (for example a database that is not up yet) do not use up the limit. Create a drop-in file:
sudo systemctl edit myapp.service

Add:

[Unit] StartLimitIntervalSec=300 StartLimitBurst=5 [Service] Restart=on-failure RestartSec=10

Note: StartLimitIntervalSec and StartLimitBurst belong in [Unit]. Older systemd versions accepted StartLimitInterval= in [Service], but newer versions ignore it there with a warning.

To keep retrying forever, set StartLimitIntervalSec=0. This turns off the start limit entirely.

  1. Clear the failed state and start the service again:
sudo systemctl daemon-reload sudo systemctl reset-failed myapp.service sudo systemctl start myapp.service

Tip: If the service depends on the network or another service, it is better to add After= and Wants= (for example After=network-online.target postgresql.service) than to rely on restarts.

Verify#

Check that the service is running and that the drop-in file is applied:

systemctl status myapp.service systemctl cat myapp.service

Confirm the new limits are active:

systemctl show myapp.service -p RestartUSec -p StartLimitBurst -p StartLimitIntervalUSec
RestartUSec=10s StartLimitBurst=5 StartLimitIntervalUSec=5min

Watch the journal for a few minutes and confirm that NRestarts does not keep going up:

journalctl -u myapp.service -f systemctl show myapp.service -p NRestarts