Mariadb isn't accessible through tunnel

When i try to connect to my mariadb server that i host on my pi I recieve and error that it can’t connect to localhost. I already have tried different options like pointing it to the local IP address of my pi or just using the docker container ID. But all of that was without any success. I hope someone here can help me solving this issue

Have you followed Arbitrary TCP · Cloudflare Zero Trust docs?

I have tried it now using the command and it created a temporary url for me.

When i go to the URL it gives me this error:

You need to have mariadb connect to the local url.

What I have it everything runs in dockers but in the same docker network. I run the commands in the cloudflare docker and it create a “trycloudflare. com” URL. I used the localhost:3306 because that is the port when i go to my pi’s ip address.

docker exec -it dockers_cloudflare-cloudflared-1 cloudflared tunnel --url tcp:// 192. 168. 0. 102:3306

Or I’m misunderstanding you or I’m doing something wrong.

Confused on what you are trying to do. If they are all on the same docker network, then you don’t need to use cloudflared to connect to your database.

What you are trying to do probably won’t easily work in a docker container as you need to run cloudflared access tcp --hostname databases.mycoolsite.com --url localhost:9210 which opens a browser window to have the user authenticate. You should have cloudflared install on your host machine and use cloudflared access tcp --hostname databases.mycoolsite.com --url localhost:9210 then connect your MySQL application to localhost:9210.

I’m trying it so i also can connect external to tha database. But i will try doing it again

Going to be hard to do it in docker and I have never done it before. Basically you need to have a client cloudflared container logged into and running the access command then the point your other docker container that needs to DB connect to the cloudflared container.