Skip to content

WebSocket connections fail for logs/monitoring when HTTP/2 is enabled in Traefik (default configuration) #4202

@JorgeHI

Description

@JorgeHI

To Reproduce

  1. Install Dokploy v0.28.8 with default configuration
  2. Deploy any application (e.g., a Next.js app)
  3. Go to the application's Deployments tab and click on any past deployment to view its logs
  4. The deployment logs dialog opens but stays in a loading state indefinitely - logs never appear
  5. Go to the application's Logs tab
  6. You can select a container from the dropdown, but the logs widget never loads - it remains empty
  7. Open browser DevTools (F12) → Console tab
  8. You will see WebSocket errors like:
    WebSocket connection to 'wss://your-domain/listen-deployment?logPath=/etc/dokploy/logs/app/app-2026-04-11:15:47:42.log' failed:
    WebSocket error: Event {isTrusted: true, type: 'error', target: WebSocket, ...}
    

Root cause investigation:

  1. SSH into the server and test WebSocket through Traefik with HTTP/2:

    curl -v -N -k -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: your-domain.com" -H "Sec-WebSocket-Key: dGVzdA==" -H "Sec-WebSocket-Version: 13" "https://localhost:443/listen-deployment?logPath=/etc/dokploy/logs/app/app.log"

    Result: HTTP/2 404 - WebSocket upgrade fails because HTTP/2 doesn't use the traditional "Upgrade" header

  2. Test with HTTP/1.1 forced:

    curl --http1.1 -v -N -k -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: your-domain.com" -H "Sec-WebSocket-Key: dGVzdA==" -H "Sec-WebSocket-Version: 13" "https://localhost:443/listen-deployment?logPath=/etc/dokploy/logs/app/app.log"

    Result: HTTP/1.1 400 Bad Request - WebSocket endpoint is reached (400 is expected with curl, not a real WS client)

Current vs. Expected behavior

Current behavior:

  • The default traefik.yml configuration enables HTTP/2 and HTTP/3
  • Modern browsers negotiate HTTP/2 with Traefik via ALPN
  • WebSocket connections fail because HTTP/2 handles WebSockets differently (no "Upgrade" header mechanism)
  • Users cannot view deployment logs or container logs in the Dokploy UI
  • The logs panel shows infinite loading state

Expected behavior:

  • WebSocket connections for logs/monitoring should work out of the box
  • Either HTTP/2 should be disabled by default, or Traefik should be configured to handle WebSockets over HTTP/2 properly

Provide environment information

- **Operating System:** Ubuntu 24.04 LTS (x86_64)
- **Dokploy version:** v0.28.8
- **VPS Provider:** Hostinger
- **Applications deployed:** Next.js applications, Node.js APIs
- **Reverse proxy:** Using Cloudflare proxy (but issue also occurs without Cloudflare)

Which area(s) are affected? (Select all that apply)

Traefik

Are you deploying the applications where Dokploy is installed or on a remote server?

Same server where Dokploy is installed

Additional context

How we discovered the root cause:

Initially, I suspected the issue was related to Cloudflare proxy or firewall configuration. After extensive debugging:

  1. Checked Docker containers - all Dokploy containers running correctly
  2. Verified disk space and PostgreSQL logs - no issues
  3. Noticed browser console errors showing WebSocket failures
  4. Bypassed Cloudflare proxy to test direct connection - same WebSocket errors persisted
  5. Tested WebSocket endpoint directly on port 3000 (Dokploy) - worked correctly
  6. Tested WebSocket through Traefik port 443 - failed with HTTP/2 404
  7. Tested WebSocket through Traefik with --http1.1 flag - worked correctly

This confirmed that HTTP/2 negotiation between browser and Traefik was breaking the WebSocket upgrade mechanism.

Default traefik.yml (problematic):

entryPoints:
  web:
    address: :80
  websecure:
    address: :443
    http3:
      advertisedPort: 443
    http:
      tls:
        certResolver: letsencrypt

Fixed traefik.yml (working):

entryPoints:
  web:
    address: :80
  websecure:
    address: :443
    http2:
      maxConcurrentStreams: 0
    http:
      tls:
        certResolver: letsencrypt

The fix disables HTTP/2 by setting maxConcurrentStreams: 0, which forces browsers to use HTTP/1.1 where traditional WebSocket upgrades work correctly.

Possible solutions:

  1. Quick fix: Change default Traefik configuration to disable HTTP/2 for the websecure entrypoint
  2. Better fix: Implement proper HTTP/2 WebSocket support (RFC 8441) in Dokploy's WebSocket endpoints
  3. Documentation: Add a troubleshooting section about this issue for users who enable HTTP/2

However I would appreciate feedback about the approach I followed, thanks!

Will you send a PR to fix it?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions