Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ca_amazing's avatar

Starting up a Laravel Queue works locally but NOT on Heroku!

Hi! First: much love to laracasts. Have gotten a lot of help from this community over this project.

I am creating a simple webapp for my parents company, one of the uses is to send a bunch of emails. In order not to get timed out I need to send them asynchronously.

I made my Model Queable, and am sending the email via

\Mail::to($application->email)->queue($email_to_send);

I changed QUEUE_DRIVER to 'database' in .env

I have set up the database table

php artisan queue:table
php artisan migrate

for the job list.

To the situation: If I run the queue locally, everything works fine. It immediately detects the jobs and sends them. I have tried a combination of these commands, with parameters, with without daemon, listen and work.

php artisan queue:listen
php artisan queue:work --sleep=3 --tries=3 --daemon

And all work fine locally. However, when I try to deploy to Heroku, it executes the line but nothing else happens.

My Procfile looks like this

web: vendor/bin/heroku-php-apache2 public/
worker: php artisan queue:work --sleep=3 --tries=3 --daemon

In my Heroku dashboard, I can see that the dyno is there. I have scaled it up, both programatically and by GUI to make sure that it has resources. When I restart dynos, by deploying code or by GUI, it says:

2018-10-30T10:46:41.607839+00:00 heroku[worker.1]: Starting process with command php artisan queue:work --sleep=3 --tries=3 --daemon

but after that, nothing happens. If I run the exact same command locally, it tells me immediately

Macs-MBP:klarait ca$ php artisan queue:work --sleep=3 --tries=3 --daemon [2018-10-30 10:45:05] Processing: App\Mail\SentMail [2018-10-30 10:45:08] Processed: App\Mail\SentMail

So.. Any ideas? I do not understand why it works so well locally but not on Heroku. Help warmly appreciated!

0 likes
1 reply
ca_amazing's avatar

A second after writing this I realised that I had only changed my local environment variables!

With

heroku config:set QUEUE_DRIVER=database

everything worked like a charm ^_^

Please or to participate in this conversation.