Cloudflare Tunnels - Connection Refused

Hello. I am running a code server on a Linux VPS within Docker, I have made a tunnel pointing to the server's localhost:8443 and cloudflare reports the tunnel as healthy. However, when I attempt to access the tunnel via its URL, the 502 Bad Gateway page shows up. However, if I peek into my cloudflared's docker logs, it reports that the connection has been refused.
2023-09-16T09:38:33Z ERR error="dial tcp 127.0.0.1:8443: connect: connection refused" cfRay=8078231e5d2f55ea-LHR event=1 ingressRule=0 originService=tcp://localhost:8443
2023-09-16T09:38:33Z ERR Request failed error="dial tcp 127.0.0.1:8443: connect: connection refused" connIndex=0 dest=https://code.cobaltonline.net/ event=0 ip=198.41.192.77 type=http
2023-09-16T09:38:33Z ERR error="dial tcp 127.0.0.1:8443: connect: connection refused" cfRay=8078231f881055ea-LHR event=1 ingressRule=0 originService=tcp://localhost:8443
2023-09-16T09:38:33Z ERR Request failed error="dial tcp 127.0.0.1:8443: connect: connection refused" connIndex=0 dest=https://code.cobaltonline.net/ event=0 ip=198.41.192.77 type=http
2023-09-16T09:38:33Z ERR error="dial tcp 127.0.0.1:8443: connect: connection refused" cfRay=807823208a3d55ea-LHR event=1 ingressRule=0 originService=tcp://localhost:8443
2023-09-16T09:38:33Z ERR Request failed error="dial tcp 127.0.0.1:8443: connect: connection refused" connIndex=0 dest=https://code.cobaltonline.net/ event=0 ip=198.41.192.77 type=http
2023-09-16T09:38:33Z ERR error="dial tcp 127.0.0.1:8443: connect: connection refused" cfRay=8078231e5d2f55ea-LHR event=1 ingressRule=0 originService=tcp://localhost:8443
2023-09-16T09:38:33Z ERR Request failed error="dial tcp 127.0.0.1:8443: connect: connection refused" connIndex=0 dest=https://code.cobaltonline.net/ event=0 ip=198.41.192.77 type=http
2023-09-16T09:38:33Z ERR error="dial tcp 127.0.0.1:8443: connect: connection refused" cfRay=8078231f881055ea-LHR event=1 ingressRule=0 originService=tcp://localhost:8443
2023-09-16T09:38:33Z ERR Request failed error="dial tcp 127.0.0.1:8443: connect: connection refused" connIndex=0 dest=https://code.cobaltonline.net/ event=0 ip=198.41.192.77 type=http
2023-09-16T09:38:33Z ERR error="dial tcp 127.0.0.1:8443: connect: connection refused" cfRay=807823208a3d55ea-LHR event=1 ingressRule=0 originService=tcp://localhost:8443
2023-09-16T09:38:33Z ERR Request failed error="dial tcp 127.0.0.1:8443: connect: connection refused" connIndex=0 dest=https://code.cobaltonline.net/ event=0 ip=198.41.192.77 type=http
2 Replies
cobalt
cobaltOP16mo ago
version: "2.1"
services:
code-server:
image: lscr.io/linuxserver/code-server:latest
container_name: code-server
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
- PASSWORD=tryhackme
- SUDO_PASSWORD=root!
- DEFAULT_WORKSPACE=/config/workspace #optional
volumes:
- /home/cobalt/devserver/code-server:/config
ports:
- 8443:8443
networks:
- code-server
restart: unless-stopped
cloudflared:
image: cloudflare/cloudflared:latest
container_name: cloudflared
restart: unless-stopped
command: tunnel run
environment:
- TUNNEL_TOKEN=token
networks:
- code-server

networks:
code-server:
name: code-server-net
external: true
version: "2.1"
services:
code-server:
image: lscr.io/linuxserver/code-server:latest
container_name: code-server
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
- PASSWORD=tryhackme
- SUDO_PASSWORD=root!
- DEFAULT_WORKSPACE=/config/workspace #optional
volumes:
- /home/cobalt/devserver/code-server:/config
ports:
- 8443:8443
networks:
- code-server
restart: unless-stopped
cloudflared:
image: cloudflare/cloudflared:latest
container_name: cloudflared
restart: unless-stopped
command: tunnel run
environment:
- TUNNEL_TOKEN=token
networks:
- code-server

networks:
code-server:
name: code-server-net
external: true
Here's my docker-compose.yml
Cyb3r-Jak3
Cyb3r-Jak316mo ago
You need to change your tunnel config to point to http://code-server:8443. localhost is the cloudflared container

Did you find this page helpful?