I’m trying to implement a real-time notification system in my Laravel application. The frontend uses jQuery, and the backend uses Laravel’s broadcasting system with Reverb (also tried with Octane and Laravel WebSockets). Everything works perfectly in my local development environment, but in production the WebSocket connection consistently fails. The browser console shows errors like “WebSocket connection could not be established” or “Failed to establish WebSocket connection.” My SSL configuration is valid, the app is running over HTTPS, and all related environment variables seem correct. I’ve already tried adjusting broadcast drivers, checking ports, restarting services, clearing config caches, and testing different Reverb/WebSocket setups, but the issue only appears in production. I’m looking for guidance on what might cause WebSockets to fail only in production and what the correct deployment or configuration steps would be for Laravel Reverb/WebSockets on a live server—especially when using jQuery and not using Node.js or a typical frontend build pipeline.
3 Replies
Check on your server production if there are any firewall block it and check the configuration file for your WebSocket server (Laravel WebSockets config or Reverb) to ensure it's listening for wss:// connections. For Laravel WebSockets, the config file is typically config/websockets.php
When WebSockets work locally but fail in production, it’s almost always the server/proxy, not Laravel.
Check these 3 things:
1, Nginx/Apache must allow WebSocket upgrade headers: Upgrade / Connection: upgrade
2, Use wss:// in production (not ws://).
3, WebSocket port must be open and the Reverb/WebSocket process must be running (Supervisor/systemd).
If any of these are wrong, the browser will fail the connection every time.