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

tinfoilman's avatar

Vapor broadcast to pusher

I'm having trouble getting events to broadcast to Pusher on an application deployed with Laravel Vapor. It's actually the "Lets Get Real With Laravel Echo" tutorial.

The thing is that works perfectly fine on my local machine, but I can't get messages to send when deployed from Vapor! I can see that the vapor site is connecting to Pusher just fine, and it's even able to receive messages that are broadcast from my local machine. I've also confirmed that the vapor site is persisting the data to the database.

Without digging into the code, is there something obviously different with a Vapor deployment that could be affecting the broadcasting to Pusher?

0 likes
8 replies
tinfoilman's avatar
tinfoilman
OP
Best Answer
Level 6

I figured out how to get it to work even though I don't understand why. Maybe someone can explain?

config/broadcasting.php needs the Pusher connection variables, like 'key' => env('PUSHER_APP_KEY') but apparently it wasn't grabbing them from the .env file!

I manually wrote in the values in the broadcasting.php file and now it works! Last night I had tried submitting the env variables in the Vapor dashboard "Secrets" and that didn't work.

Tippin's avatar

If you ever ran this in the past

php artisan config:cache

Then you need to run it everytime after you deploy and have new/updated config files/values.

Also double check the key name matches exactly what you have in your .env, and that your server is pulling the proper .env if you are using a shared/persistent image or volume for it. Also I do not think the pusher key should be in quotes when in your env, so check on that as well.

tinfoilman's avatar

Thanks for the tip. I remember having to use that months ago!

But it's still odd because I know the .env variables are successfully being used elsewhere in the project because it was connected to Pusher and receiving data. It was just the broadcasting that didn't work.

I'm going to try reverting back to the .env references in the broadcasting.php file and see if the config:cache makes it work.

1 like
tinfoilman's avatar

OK, so it's not the config:cache, which I'm kind of glad about because you would think that Vapor would start fresh on deployment.

I put the variables back in broadcasting.php and it works again. They do need quotes in broadcasting.php, but no quotes in the .env

1 like
tinfoilman's avatar

Thanks for the help, but at least it's working, so it's more of a curiosity thing.

mboynes's avatar

I think I just ran into this myself. What I had to do was run vapor env:pull production to download the env.production file, then run vapor deploy production and that looks to have done the trick.

I'm new to Vapor so take my assumptions with a grain of salt: It appears as though the deployment will use the appropriate .env file for the environment it is deploying to, but that file must be present wherever the build is running. In my case, I'm running the build locally, and didn't have .env.production locally, so it was using .env, which had the wrong API key.

Please or to participate in this conversation.