One of my Cloudflare Tunnels is returning a Bad Gateway error

I have setup my Tunnel and have the connector running on a VM on my network. I have setup several tunnels in Cloudflare and they all work beside my Portainer one. I get the 502 Bad Gateway error. I really would like to solve why this one is not working. I have deleted it and recreated it a few times to make sure I didn’t enter something wrong. I don’t even know where to go to find logs to help me determine the issue. Any help is greatly appreciated.

My Docker environment is running on an Ubuntu 22.10.1 server as a VM with Docker installed on it.

Hi there,

For a 502 Bad Gateway on a tunnel, you will need to check the logs for cloudflared. Basically it means that the connection between Cloudflare and the tunnel is active, but the tunnel cannot access your origin service.

If using docker, run docker ps to get the container ID and then run docker logs <id> to grab the logs.

Note also for Docker, if you are using a localhost or 127.0.0.1 service this might not work due to network isolation.

Here is what the log is showing. Just so you know all the other tunnels setup in this are working and are all on the same docker server. Also just so you know I have a total of 5 tunnels setup and the other 4 are all working and are on the same docker server.

these are the two errors in the log.

2023-03-13T20:49:50Z ERR error=“Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: x509: certificate is valid for 0.0.0.0, not 192.168.0.121” cfRay=7a7725505ecee27f-ORD ingressRule=4 originService=htt ps://192.168.0.121:9443
2023-03-13T20:49:50Z ERR Request failed error=“Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: x509: certificate is valid for 0.0.0.0, not 192.168.0.121” connIndex=3 dest=h ttps://portainer.reynoldshome.us/ ip=198.41.192.37 type=http

I got this working by going into the Tunnel setup and enabling no-tls-verify on the tunnel.

8 Likes

Hey hi can you please help me where did you do this i also use portainer docker and i am getting 502 errors every few times… Where did you turn off the tls inside Cloudflare dashboard or the docker server?


Edit public hostname then use “HTTPS” - Additional application settings - TLS - No TLS Verify - Enabled

3 Likes

Hi gearwhore
This solution method also worked for me without any problems. Now I can successfully connect to Cloudflare Tunnel via proxmox IP address.
THANK YOU :slight_smile:

Thank you, I have solved this problem.

1 Like