Create a caddy websocket url instead of http

1. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

2. How I installed and ran Caddy:

I follow this links to install caddy

a. System environment:

Operating System: Debian 11
Kernel: 5.4.128-1-pve
Architecture: x86_64

b. Command:

caddy start
caddy stop

My complete Caddy config: {

        @websocket {
                header Connection *Upgrade*
                header Upgrade websocket

        reverse_proxy localhost:3005
        log {
                output file /var/log/caddy/ws.log

The problem I’m having:

For this caddy config, I am getting e URL like this ‘’ "
But I want to create a WebSocket URL like this ‘’ wss:// ‘’. So, that I can use this URL to connect with my WebSocket server.
Please help me to properly set up a WebSocket on Caddy and create a WebSocket protocol URL.

WebSocket upgrades are automatic. Remove all the @websocket stuff in your config (it isn’t being used anyway) and just have your client connect with wss:// and it will be proxied to your backend as a websocket.

Thank you for the replay, Matt.
Do you mean to change the code like this? {

        reverse_proxy localhost:3005
        log {
                output file /var/log/caddy/ws.log

but if I make these changes, I am still getting some errors like in my client I try to connect the socket through -
I am getting this error -

and if I try to connect through this URL - wss://
it says that the connection to this URL is failed.

wss means “Websockets over HTTPS”. You only configured Caddy to listen for HTTP, not HTTPS (because of http://). So you need to use ws:// for now until you enable HTTPS.

1 Like

I use ws but it still failed to connect.

You’ll need to give us more to go on than that. We can’t help if you just say “nope :man_shrugging:

Show your logs. Show what you tried, exactly. Show your current config. Etc.