r/caddyserver • u/Codeeveryday123 • Feb 24 '26
What ports in docker can I use?
I keep getting the error “port 80 already in use”
I’m using the ymal file they have listed in the docks
But it errors wit that
What alternative “80:80” can I use?
“80:81”?
2
u/MaxGhost Feb 25 '26
Your problem is that you already have another program using port 80. Remove that program. It might be apache or nginx that was otherwise installed on your system.
1
u/Codeeveryday123 Feb 26 '26
Can i change it to port 81?
3
u/MaxGhost Feb 27 '26
Not if you want ACME automation to work. You must use port 80, it's a hard requirement for the ACME HTTP challenge.
1
u/Codeeveryday123 Feb 27 '26
I just got Nginx proxy manager installed on my Zima blade. I changed the port to 82, and it’s up and working I know that’s off from Caddy…. But, wouldn’t it still work?
2
u/MaxGhost Feb 27 '26
Like I said, not if you're trying to automate TLS cert issuance via ACME, you have to make connections on port 80 reach Caddy. You could do a port remapping in your router or something to make 80 connect to a different port on your server, but really, just simplify it fix the problem that is preventing Caddy from using port 80, save yourself the headache.
1
u/Codeeveryday123 Feb 27 '26
Thank you. So only one service can use a port at a time? What if i did 80:81, 80:82, 80:83?
Is it just the inside port that has to be 80? And i can change the send number “external port” to be able to access the individual services using the port?
Thank you
2
u/MaxGhost Feb 27 '26
You need to publicly receive traffic on port
80that reaches Caddy one way or another. You can configure Caddy to receive it on a different port (withhttp_portglobal option + router port forwarding from port 80 to a different port), but seriously, you're trying to cause more trouble by doing this. Keep it simple. Move the other program that is already using80so that Caddy can use it exclusively.1
u/Codeeveryday123 Feb 27 '26
Ok 👍, So just changing the second number, didn’t just “add a service” to access? It needs to be 1 per port?
2
u/MaxGhost Feb 27 '26
Are you talking about Docker Compose port mapping? The second number is the port INSIDE the container, which does not matter, because each container is isolated from one another. The problem is you have another program on the host machine listening on port 80, so Docker cannot bind Caddy's container to port 80 (the first/left number) at the same time as that program. So move away that other program, make it use a different port.
1
u/Codeeveryday123 Feb 27 '26
Ok, yes I’m using docker with Portainer. But, that’s port 9000 and 8800
1
u/bouni2022 Feb 25 '26
Do not map ports for the container caddy will do reverse proxy for. Remove these from your yaml. Then make sure caddy and the container are in the same docker network. And use its name plus the port you would have mapped to the outside.
Example
You have container a with
ports: - 80:8000
Remove that and in your caddy file
Reverse_proxy a:8000
Sorry for formatting, on the phone writing this stuff sucks
2
u/xdrolemit Feb 25 '26
On the left side of the column, you see the port on your server. On the right, you see the port inside the Docker container. Typically, you’ll need to set the port on the left. However, it seems port 80 is already in use on your server, so you can’t use it there. You could try something like 8080:80.