Skip to content

Disable systemd rate limiting for PHP-FPM to prevent installation fai…#7

Closed
klemenza wants to merge 4 commits into
qwatts-dev:masterfrom
klemenza:systemd-rate-limiting
Closed

Disable systemd rate limiting for PHP-FPM to prevent installation fai…#7
klemenza wants to merge 4 commits into
qwatts-dev:masterfrom
klemenza:systemd-rate-limiting

Conversation

@klemenza
Copy link
Copy Markdown

Fix PHP-FPM installation failures by disabling systemd rate limiting

Problem

On first provision, the PHP extension installation task fails with:

  • Job for php8.3-fpm.service failed.
  • Start request repeated too quickly.
  • Failed with result 'start-limit-hit'.
  • dpkg: error processing package php8.3-fpm (--configure)

This only happens on first provision because:

  1. Trellis installs multiple PHP extensions in a loop (php8.3-bcmath, php8.3-cli, php8.3-curl, etc.)
  2. Each extension installation triggers php-fpm to restart via dpkg post-install hooks
  3. Systemd's default rate limit is 5 starts per 10 seconds
  4. With 10+ extensions installing, php-fpm hits this limit
  5. Systemd blocks further restarts and dpkg fails

On subsequent provisions, extensions are already installed (no restarts triggered), so the issue doesn't occur.

Solution

Add a systemd override during bootstrap that disables rate limiting for php8.3-fpm.service:

mkdir -p /etc/systemd/system/php8.3-fpm.service.d
cat > /etc/systemd/system/php8.3-fpm.service.d/override.conf << 'EOF'
[Unit]
StartLimitIntervalSec=0
EOF

Setting StartLimitIntervalSec=0 tells systemd to never enforce rate limits on this service, allowing unlimited restarts during the package installation loop.

Why WSL-specific

This is particularly problematic in WSL2 because:

Fresh distros are bootstrapped and provisioned in one flow
The entire stack (Ansible + PHP + all extensions) installs in minutes
The rapid-fire dpkg operations hit systemd limits that production servers never see (they install packages gradually over time)

Testing

Tested on Windows 11 with WSL2 Ubuntu 24.04. PHP 8.3 and all extensions now install successfully on first provision without start-limit-hit errors.

@klemenza klemenza closed this May 12, 2026
@klemenza klemenza deleted the systemd-rate-limiting branch May 12, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant