Tooling

Laravel Forge: Restart Queue Worker via Deployment Script

Chris
Managing Director, Senior PHP Developer
Updated:
Modern office workspace with laptop and coffee setup.

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”):

Laravel Forge Redis Worker Status Dialog.

You will then see a dialog like this, where the worker name is listed:

Laravel Forge: Check Queue and Deamon ID for restart via Deployment Script.

Now add the command (sudo -S supervisorctl restart worker-5432987:worker-5432987_00) to the Forge Scheduler to run every night:

Laravel Forge: Restart Redis via Forge Scheduler.

You can also place this command directly in your deployment script.

Search

Chris Wolf

Chris Wolf

Managing Director, Senior PHP Developer

From the first call to delivery, you talk to me. Call, book an appointment or send me a message.

Send us a message