Visor guides

FATAL Exited too quickly

Why a program goes BACKOFF, then FATAL, and how to find the cause.

Visor showing a program stuck in Fatal after it exited too quickly, with its last error and a Restart button
  • supervisord
  • FATAL
  • troubleshooting

supervisorctl status shows:

myapp                            FATAL     Exited too quickly (process log may have details)

and supervisorctl start myapp prints myapp: ERROR (spawn error). supervisord started the program, the program quit within a second, supervisord tried a few more times, and then gave up. supervisord is working as intended. The program stopped by itself, and its own output says why.

What supervisord did

A program counts as started once it has stayed up for startsecs seconds, 1 by default. If it exits sooner, it goes to BACKOFF, and supervisord tries again, waiting a second longer each time, up to startretries more times, 3 by default. After that it’s FATAL. A FATAL program stays stopped, even with autorestart=true, until you start it. startsecs and startretries has the details, and supervisord’s docs the reference.

supervisord’s own log shows each try. Read it with supervisorctl maintail:

INFO spawned: 'myapp' with pid 4321
WARN exited: myapp (exit status 1; not expected)
INFO spawned: 'myapp' with pid 4325
WARN exited: myapp (exit status 1; not expected)
INFO spawned: 'myapp' with pid 4330
WARN exited: myapp (exit status 1; not expected)
INFO spawned: 'myapp' with pid 4336
WARN exited: myapp (exit status 1; not expected)
INFO gave up: myapp entered FATAL state, too many start retries too quickly

Each line starts with the date and time. The exit status is the program’s, and it’s the first clue: the program reported an error, rather than being killed.

Read the program’s log

supervisorctl tail myapp stderr

With redirect_stderr=true, errors go to the stdout log instead: supervisorctl tail myapp. Add -f to follow it while you start the program again. If both are empty, the program died before it printed anything, or it writes to its own log file, such as Laravel’s storage/logs/laravel.log.

Run it the way supervisord does

Take command= and directory= from the config and run them by hand, as the user= in the config if there is one:

cd /srv/myapp
sudo -u www-data /usr/bin/php artisan queue:work

When it works in your terminal but not under supervisord, it’s usually one of these:

  • PATH is shorter. supervisord passes on the environment it was started with. Under launchd (brew services) or systemd that has no Homebrew, nvm, pyenv or ~/.local/bin. Use the full path to the program in command=.
  • There’s no shell. supervisord runs the command directly, so &&, pipes, > and source venv/bin/activate don’t work. Put them in a script that ends with exec and the real command, or point command= at the virtualenv’s own binary, such as /srv/myapp/.venv/bin/gunicorn.
  • The environment is different. user= changes the user, not HOME, USER or PATH, which stay as supervisord had them. Set what the program needs with environment=, for example environment=HOME="/home/deploy",APP_ENV="production".
  • directory= doesn’t exist, or the user can’t read the files there.

Programs that go to the background

supervisord expects a program to stay in the foreground. A program that starts a copy of itself in the background and exits looks to supervisord like a crash. Turn its daemon mode off:

Keeping common programs in the foreground
ProgramRun it as
nginxnginx -g 'daemon off;'
Redisredis-server --daemonize no
PHP-FPMphp-fpm --nodaemonize
Gunicornwithout --daemon
Celerycelery worker, without --detach or celery multi
pm2pm2-runtime in place of pm2 start

Programs meant to exit

A one-off script or php artisan schedule:run exits when it’s done, and supervisord can’t tell that from a crash. Tell it:

startsecs=0
autorestart=unexpected
exitcodes=0

startsecs=0 counts the start as good straight away. autorestart=unexpected with exitcodes=0 starts it again only when it fails. For Laravel’s scheduler, use schedule:work, which stays in the foreground; see Laravel Horizon on a Mac.

Start it again

Fix the cause. If you changed the config, load it, which also starts the program again:

supervisorctl update

If you fixed something outside the config, start it yourself:

supervisorctl start myapp

Watch it with supervisorctl status: it should go from STARTING to RUNNING after startsecs.

Messages that look alike

  • BACKOFF Exited too quickly …: supervisord is still retrying. It becomes FATAL after the last try.
  • FATAL can't find command '/srv/myapp/bin/server': supervisord couldn’t run the command at all. The path is wrong, or the program isn’t on supervisord’s PATH.
  • EXITED: the program ran past startsecs, then exited, and autorestart didn’t start it again.
  • ERROR (no such process): supervisord hasn’t loaded that program. See A program isn’t loaded.

With Visor

In Visor, the config’s page opens with the Last error. It shows supervisord’s reason and how many times it tried, for example Exited too quickly (process log may have details). supervisord gave up after 4 start attempts., and the last lines of stderr under it, with Restart, Open stderr log and Open in editor. When a line of the config caused it, Caused by line links to that line and its fix. A program that reaches FATAL also opens a Can’t start issue and can notify you. See A program won’t start and Issues and notifications.

Edit this page on GitHub

The text is under CC BY 4.0: reuse it with credit to Touhidur Rahman and a link to this page. The code examples are free to copy.