Safeguard
Security Guides•

Do Laravel queue workers keep running old code after a deploy?

Yes. Laravel queue workers hold the booted app in memory, so patched code and rotated secrets are ignored until you restart them. Here is the deploy routine.

Safeguard Security Team
3 min read

Yes. Laravel queue workers are long-lived processes that keep the booted application in memory, so they do not notice code changes until restarted. After a security patch, a dependency update or a secret rotation, run php artisan queue:restart as part of every deploy.

Why this is a security issue, not just a bug

The Laravel documentation states that workers store the booted application state in memory and will not see changes to your code base once started. It adds that static state is not reset between jobs.

Think about what that means after a fix. You merge a patch for a validation flaw, deploy, and the web servers run the new code. If the workers were not restarted, background jobs still execute the vulnerable version. The same goes for rotated credentials and a new APP_KEY: a worker that booted before the change keeps using what it loaded.

The routine

php artisan queue:restart

The documented behaviour is a graceful restart. Workers finish the job they are on, then exit, and your process manager starts fresh ones. The documentation recommends running workers under Supervisor so a stopped worker comes back automatically.

OptionWhat it doesWhen to use
queue:restart in deploy scriptGraceful restart of all workersEvery deploy
queue:listenReloads code each job, but is slowerLocal development
Max jobs option with SupervisorWorker exits after N jobsLimit memory growth
Max time option with SupervisorWorker exits after N secondsBound how stale a worker can get

The max jobs and max time options are described in the docs as ways to release accumulated memory, but they also put a ceiling on how long a worker can run old state.

Checklist for a patch deploy

  1. Deploy the code and update the environment.
  2. Run php artisan optimize if you cache config, routes and views.
  3. Run php artisan queue:restart.
  4. Confirm Supervisor started new worker processes.
  5. Check worker start times, not only web responses.
  6. Watch the failed jobs list for new errors.

Step 5 is the one people skip. A healthy website tells you nothing about the age of a worker.

Watch the timeout interplay

By default the job timeout is 60 seconds, and a job running past it makes the worker exit with an error. Your process manager normally restarts it. If a job has a long timeout, a graceful restart waits for it to finish, so a patch may take that long to reach all workers. For urgent fixes, know your longest timeout.

Quick check

Does queue:restart kill running jobs?

No. It signals workers to exit after they finish the current job, so in flight work is not cut off.

What if I forget to restart?

Workers keep running the version they booted with, including vulnerable code or an old secret, until they exit for another reason.

Safeguard's reachability analysis and fix pull requests can show which updates matter for your code, and autonomous remediation is off by default. A free scan is at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.