Queues are one of the best parts of Laravel. You move slow work out of the request, users stop waiting, and the app feels fast. Then one day an invoice email goes out twice, a report never arrives, or a job runs against data that isn't there yet. Nothing in the logs looks wrong.
Almost every queue problem we've had to untangle came from a short list of mistakes. Here they are, with the fix for each. Code follows the Laravel 13 queue docs; where Laravel 12 differs, it's noted.
1. The queue isn't actually a queue
If QUEUE_CONNECTION is sync, Laravel runs every dispatched job immediately, inside the request. Nothing breaks, so nobody notices. Pages are just slow, and a failing job throws an error at the user.
Check your production .env:
QUEUE_CONNECTION=redis sync is fine in local development and tests. In production, use redis, database or sqs, and make sure a worker is running to process it.
2. Workers run old code after a deploy
queue:work boots your app once and keeps it in memory. After you deploy, the workers carry on with the code they started with until they restart. That's how a bug you fixed this morning keeps happening this afternoon.
Add this to every deploy, after the new code is in place:
php artisan queue:restart It tells workers to exit after their current job. Something has to bring them back up, which is what Supervisor is for. This is the config from the Laravel docs:
[program:laravel-worker] process_name=%(program_name)s_%(process_num)02d command=php /home/forge/app.com/artisan queue:work --sleep=3 --tries=3 --max-time=3600 autostart=true autorestart=true stopasgroup=true killasgroup=true user=forge numprocs=8 redirect_stderr=true stdout_logfile=/home/forge/app.com/worker.log stopwaitsecs=3600 Set stopwaitsecs higher than your longest job takes. Otherwise Supervisor can kill a job halfway through when it stops a worker.
3. --timeout is longer than retry_after
This one causes duplicate jobs, and it's easy to miss. Two different settings control time:
-
--timeouton the worker (60 seconds by default): how long a job may run before the worker kills it. -
retry_afteron the queue connection inconfig/queue.php(90 by default): how long the queue waits before it assumes a job is lost and hands it to another worker.
If a job can run longer than retry_after, a second worker picks it up while the first is still working. Both finish. The customer gets two emails.
The docs put it plainly: --timeout should always be at least several seconds shorter than retry_after. If you have a job that needs five minutes, raise both, and keep the gap.
4. The job runs before the data exists
You create an order inside a database transaction and dispatch a job to process it. The worker is fast, picks up the job before the transaction commits, looks for the order, and can't find it.
Tell Laravel to wait for the commit:
DB::transaction(function () use ($data) { $order = Order::create($data); ProcessOrder::dispatch($order)->afterCommit(); }); Or set 'after_commit' => true on the queue connection in config/queue.php so every job dispatched inside a transaction waits by default. If the transaction rolls back, the job is never sent at all, which is usually what you want.
5. Jobs fail once and are gone
A third-party API times out for ten seconds and every job that hit it in those ten seconds is marked failed. Give jobs room to retry, with a delay that grows each time:
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Queue\Queueable; use Illuminate\Queue\Attributes\Backoff; use Illuminate\Queue\Attributes\Tries; use Throwable; #[Tries(3)] #[Backoff([10, 60, 300])] class SyncInvoiceToAccounting implements ShouldQueue { use Queueable; public function __construct(public Invoice $invoice) {} public function handle(): void { // call the accounting API } public function failed(?Throwable $exception): void { // tell someone: log it, alert the team, flag the invoice } } On Laravel 12, use the public $tries = 3; and public $backoff = [10, 60, 300]; properties instead of the attributes.
Failed jobs land in the failed_jobs table. Look at them. php artisan queue:failed lists them, and php artisan queue:retry all sends them back once the cause is fixed. A failed-jobs table that nobody reads is the same as losing the work.
6. The same job runs twice at the same time
Retries, double-clicks and scheduled tasks all create duplicates. Two copies of "recalculate this account's balance" running at once is how numbers drift.
Laravel gives you two tools. If only one copy of a job should ever be waiting in the queue, implement ShouldBeUnique:
use Illuminate\Contracts\Queue\ShouldBeUnique; class RecalculateBalance implements ShouldQueue, ShouldBeUnique { use Queueable; public function __construct(public Account $account) {} public function uniqueId(): string { return (string) $this->account->id; } } Unique jobs need a cache driver that supports locks (Redis, Memcached, DynamoDB, database, file or array).
If duplicates may queue up but must not run at the same moment, use the WithoutOverlapping middleware instead:
use Illuminate\Queue\Middleware\WithoutOverlapping; public function middleware(): array { return [new WithoutOverlapping($this->account->id)]; } Neither replaces writing jobs that are safe to run twice. Check whether the work is already done before doing it, and you're protected even when something slips through.
7. Nobody notices the queue is backing up
Workers crash, Redis fills up, a slow job blocks everything behind it. Users notice before you do.
Laravel can watch queue size for you. Schedule this to run every minute:
php artisan queue:monitor redis:default --max=100 When the queue holds more than 100 jobs, Laravel fires a QueueBusy event. Listen for it and send yourself a message. If you run Redis queues, Laravel Horizon adds a dashboard with throughput, wait times and failed jobs, and it handles the worker processes too.
A short checklist
-
QUEUE_CONNECTIONisn'tsyncin production -
queue:restartruns on every deploy; Supervisor restarts workers -
--timeoutis several seconds shorter thanretry_after - Jobs dispatched inside transactions use
afterCommit() - Jobs have tries, backoff and a
failed()method; someone readsfailed_jobs - Jobs that must not double up use
ShouldBeUniqueorWithoutOverlapping - Queue size is monitored and alerts someone
The full details are in the Laravel queue documentation, which is one of the better-written parts of the docs.
This is the list our team goes through whenever we take over a Laravel app with "random" queue problems. If you need help with that kind of work, you can hire Laravel developers from our team.
Disclosure: I work at EchoInnovate IT, a software development company with teams in the USA and India.
Which of these has caught you out? I'd like to hear about it in the comments.