Understanding and Fixing “service start request repeated too quickly” Error in systemd Services


2 views

When systemd throws the service start request repeated too quickly, refusing to start error, it's enforcing a protective mechanism against service thrashing. This occurs when a service configured with Restart=on-failure or similar restart policies fails repeatedly in quick succession.

systemd implements a default rate-limiting behavior through two key parameters:


# Default values in systemd
StartLimitIntervalSec=10s
StartLimitBurst=5

This means if a service fails more than 5 times within 10 seconds, systemd will block further restart attempts.

Check your service's current configuration with:


systemctl show your-service.service | grep -E "StartLimitInterval|StartLimitBurst"

The most straightforward fix is to adjust these limits in your service unit file:


[Unit]
Description=My Service
After=network.target

[Service]
ExecStart=/usr/bin/my-service
Restart=on-failure
StartLimitIntervalSec=60s
StartLimitBurst=10

[Install]
WantedBy=multi-user.target

For services that need immediate restart capability:


[Service]
...
RestartSec=5s  # Add delay between restart attempts
StartLimitIntervalSec=0  # Disable rate limiting completely

Before adjusting limits, investigate why the service fails:


journalctl -u your-service.service -b --no-pager -n 50
systemctl status your-service.service
  • Always log service failures properly
  • Implement exponential backoff in your application
  • Consider using Restart=on-abnormal instead of on-failure
  • Monitor restart patterns with systemd-analyze critical-chain your-service.service

Here's how we fixed a database connection service:


[Service]
ExecStart=/usr/local/bin/db-connector
Restart=on-failure
RestartSec=10s
StartLimitIntervalSec=1min
StartLimitBurst=3

This configuration allows for quick initial recovery but prevents runaway restarts.


When you encounter the message service start request repeated too quickly, refusing to start, you're seeing systemd's built-in protection against service thrashing. The exact threshold is defined by two key parameters in the service unit file:


# Default values if not specified:
StartLimitIntervalSec=10s
StartLimitBurst=5

This means your service will be blocked if it attempts to restart more than 5 times within a 10-second window. These are default values that apply when not explicitly set in your service configuration.

The most frequent cases I've encountered:


1. Immediate crash loops (service starts but exits immediately)
2. Dependency failures (DB connection fails repeatedly)
3. Resource exhaustion (memory limits hit)
4. Configuration errors (invalid parameters)

Here's how to properly configure a resilient service:


[Unit]
Description=My Resilient Service

[Service]
ExecStart=/usr/bin/my-service
Restart=on-failure
# Customize restart limits:
StartLimitIntervalSec=2min
StartLimitBurst=10
# Add delay between restarts:
RestartSec=5s

[Install]
WantedBy=multi-user.target

When debugging this issue, I recommend:


# View service status with restart counts:
systemctl status myservice.service

# Check journal for crash reasons:
journalctl -u myservice.service -b -n 50

# Temporarily increase limits for testing:
systemctl set-property myservice.service StartLimitIntervalSec=30s
systemctl set-property myservice.service StartLimitBurst=100

For services depending on database availability:


[Service]
ExecStartPre=/bin/sh -c 'until pg_isready -h dbhost; do sleep 1; done'
ExecStart=/usr/bin/my-db-service
Restart=on-failure
StartLimitIntervalSec=5min
StartLimitBurst=20
RestartSec=10s

This configuration waits for DB readiness before starting and allows more frequent restarts with longer delays between attempts.