-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port is already allocated error when setting proxy to false and publishing port (on options) #1133
Comments
Hi @dihmeetree! Kamal 2 is not designed to work without kamal-proxy. You can disable the proxy, but that's for "non-web" containers where we are just going to check that the container boots correctly Either way though it will start up new container before closing the old one, so you can't publish a port like that as the second container will fail to start because the first is already using the port. |
@djmb It would be very nice if it would be somewhere highlighted in the docs that you cannot use Kamal 2 without kamal-proxy since DHH's video claims the opposite (second half of the video). Also, on https://kamal-deploy.org/docs/configuration/proxy/ it says
Highly confusing. |
@djmb What is the recommended configuration for exposing a single port from a container? Is it simply impossible? |
Any updates on this? Even when using a proxy, it is sometimes necessary to expose some ports. For example, when using clustering on Elixir/Erlang, EPMD expects port 4296 to be open. |
@pulkit110 Here is how I accomplished it for Elixir with an EPMD-less deployment on a single port 6789. accessories:
traefik:
service: traefik
image: traefik:v3.1
roles:
- web
options:
publish:
- "6789:6789"
cmd: "--providers.docker --providers.docker.exposedByDefault=false --entryPoints.epmd.address=:6789 --log.level=INFO"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
labels:
traefik.enable: true
traefik.tcp.routers.epmd.rule: "ClientIP(`0.0.0.0/0`)"
traefik.tcp.routers.epmd.priority: 5
traefik.tcp.routers.epmd.entryPoints: epmd
traefik.tcp.routers.epmd.service: epmd
traefik.tcp.services.epmd.loadBalancer.server.port: 6789 And in
|
Thanks @schrockwell, that really helped! |
My servers portion of my Kamal config looks something like this
Note here that I have
proxy:false
and i'm publishing port 3000. I'm using a different proxy than Kamal Proxy (hence why i've disabled the default proxy).When I go to re-deploy with Kamal (
kamal deploy
) I get the following errorNote: Deploying for the first time works fine! But it's only when you deploy a 2nd time you get the error.
Note the error says
Bind for 0.0.0.0:3000 failed: port is already allocated.
In order to get around this I have to remove the existing web containers, then deploy.
I've seen someone else mention this issue in the Discord, but bringing this up since I don't plan on using the built in Kamal Proxy, so it would be awesome if there was a solution/fix for this!
Edit: Decided that I will leverage the Kamal Proxy, so I can still get the zero downtime deploys.. so i've gone back to setting the proxy and everything works again. But this issue is still relevant to those who do decide to disable the built in Kamal Proxy 👍🏻
The text was updated successfully, but these errors were encountered: