itsonlyjeff's avatar

Reverb on Forge - No Connection

On my local environment, Reverb works fine. I can’t get it running on my VPS in Laravel Forge (SSL-related).

BROADCAST_CONNECTION=reverb
REVERB_APP_ID=138624
REVERB_APP_KEY=base64:cQjR32gTlNeDzg3bzUJ80CcYyT/yNN6BuQc0ro2JAas=
REVERB_APP_SECRET=xxxxxx

REVERB_SERVER_HOST=0.0.0.0
REVERB_SERVER_PORT=8080

REVERB_HOST=websockets.xxxxxx.xx
REVERB_PORT=443
REVERB_SCHEME="https"

VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"

Default Echo setup:

window.Echo = new Echo({
    broadcaster: 'reverb',
    key: import.meta.env.VITE_REVERB_APP_KEY,
    wsHost: import.meta.env.VITE_REVERB_HOST,
    wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
    wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
    forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
    enabledTransports: ['ws', 'wss'],
});

I created a DNS A record via Cloudflare (without proxying) pointing to my domain.

Via Postman I get a 404 Not Found response. And in the browser console I see:

app-CZOKv9eH.js:991 WebSocket connection to
'wss://websockets.xxxxxx.xx/app/base64:cQjR32gTlNeDzg3bzUJ80CcYyT/yNN6BuQc0ro2JAas=
?protocol=7&client=js&version=8.4.0&flash=false'
failed

Am I missing something in the configuration?

url is redacted.

0 likes
1 reply
LaryAI's avatar
Level 58

Absolutely! Let's walk through the most common issues and solutions for running Laravel Reverb behind SSL (HTTPS) on a Forge server, especially when using a separate subdomain and Cloudflare.

Key Points to Check

  1. Reverb Server Must Listen on 0.0.0.0 (already correct):

    REVERB_SERVER_HOST=0.0.0.0
    
  2. SSL Termination:
    Forge typically handles SSL on the web server (nginx), not Reverb. DON’T run Reverb with internal SSL. Run it via HTTP (port 8080, not 443). nginx will proxy wss connections from the public to Reverb.

  3. Reverb actual server config:

    REVERB_SERVER_PORT=8080
    
  4. .env for frontend (correct):

    VITE_REVERB_HOST=websockets.xxxxxx.xx
    VITE_REVERB_PORT=443
    VITE_REVERB_SCHEME=https
    
  5. WebSocket proxy settings in nginx (Forge 'Sites > Edit Nginx Files > Websockets'):
    Make sure you have a custom nginx config for the subdomain:

    Add into your subdomain's server block:

    location /app/ {
        proxy_pass             http://127.0.0.1:8080;
        proxy_http_version     1.1;
        proxy_set_header       Upgrade $http_upgrade;
        proxy_set_header       Connection "Upgrade";
        proxy_set_header       Host $host;
        proxy_set_header       X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header       X-Forwarded-Proto $scheme;
    }
    
  6. Restart nginx after saving config changes.

  7. Cloudflare settings:

    • DNS: Make sure the subdomain is set to "DNS only" (grey cloud).
    • Proxy Status: NO orange cloud. (WebSockets often won’t work when proxied by Cloudflare Free!)
    • SSL/TLS: Should be "Full" or "Full (Strict)".
  8. Reverb start script:
    Run Reverb with:

    php artisan reverb:start --host=0.0.0.0 --port=8080
    

    Or set this up as a Forge daemon.

  9. Check for firewall (UFW):
    Port 8080 should NOT be exposed to the public; only nginx proxies to it. Double-check UFW or any firewall just in case.


Example: Final setup steps

Your .env is almost correct, just be sure NOT to set Reverb's server port to 443 internally.

Your nginx, for websockets subdomain, should have:

location /app/ {
    proxy_pass             http://127.0.0.1:8080;
    proxy_http_version     1.1;
    proxy_set_header       Upgrade $http_upgrade;
    proxy_set_header       Connection "Upgrade";
    proxy_set_header       Host $host;
    proxy_set_header       X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header       X-Forwarded-Proto $scheme;
}

Checklist

  • Reverb running on 0.0.0.0:8080
  • nginx proxies /app/ traffic to Reverb
  • SSL is handled by nginx, not Reverb itself
  • Cloudflare DNS only (no proxy)
  • VITE/Echo uses wss://your-subdomain/443

Why you got a 404 in Postman

Reverb only listens on /app/ route for websocket upgrades, not normal HTTP. A plain GET in Postman to /app/ on port 443 → nginx → Reverb is not going to yield anything useful without an upgraded WebSocket handshake.


Debugging

  • Watch your browser development console for actual websocket upgrade requests and errors.
  • Use php artisan reverb:status to check if your server is running.

Let me know if you need a step-by-step guide for creating the nginx config on Forge!

Please or to participate in this conversation.