Laravel Forge: Restart Queue Worker via Deployment Script
Queue workers can occasionally fail when the database connection drops. In those cases, restarting the worker usually resolves the issue quickly.
A common error pattern in the worker logs looks like this:
In Connection.php line 825:
SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select *
from `cache` where `key` in (illuminate:queue:restart))
In Connector.php line 66:
SQLSTATE[HY000] [2002] Connection refusedLanguage:shell
With the Forge Scheduler, you can restart the worker nightly using a simple command. This improves long-term application stability.
Command to restart queue workers or daemons:
sudo -S supervisorctl restart worker-5432987:worker-5432987_00
You can find the worker/daemon ID in the status dialog (button: “Check Worker Status”):
You will then see a dialog like this, where the worker name is listed:
Now add the command (sudo -S supervisorctl restart worker-5432987:worker-5432987_00) to the Forge Scheduler to run every night:
You can also place this command directly in your deployment script.