Upgraded from Ubuntu 16.04.5 to 18.04.1 and now Caddy can't bind to port 80 or 443

Caddy use to work fine under Ubuntu 16.04.5 but after upgrading to 18.04.1 caddy fails to launch.

sudo journalctl -xef -u caddy.service:

Sep 17 02:09:46 ubuntu caddy[9872]: Activating privacy features... done.
Sep 17 02:09:46 ubuntu caddy[9872]: 2018/09/17 02:09:46 listen tcp :80: bind: address already in use
Sep 17 02:09:46 ubuntu systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
Sep 17 02:09:46 ubuntu systemd[1]: caddy.service: Failed with result 'exit-code'.
Sep 17 02:09:51 ubuntu systemd[1]: Started Caddy HTTP/2 web server.
-- Subject: Unit caddy.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit caddy.service has finished starting up.
--
-- The start-up result is RESULT.
Sep 17 02:09:51 ubuntu caddy[9915]: Activating privacy features... done.
Sep 17 02:09:51 ubuntu caddy[9915]: 2018/09/17 02:09:51 listen tcp :443: bind: address already in use
Sep 17 02:09:51 ubuntu systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
Sep 17 02:09:51 ubuntu systemd[1]: caddy.service: Failed with result 'exit-code'
michael@ubuntu:~$ netstat -ano | grep :80
tcp6       0      0 :::80                   :::*                    LISTEN      off (0.00/0/0)
michael@ubuntu:~$ netstat -ano | grep :443
tcp6       0      0 :::443                  :::*                    LISTEN      off (0.00/0/0

Things I’ve tried so far:

CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
  • I also tried sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/caddy which should have done something similar but that didn’t work either.

I’m not sure exactly what I’m missing. Can anyone help me with this?

The link you quoted was a different issue - Caddy wasn’t given permission to bind to those ports.

Looks like, from your logs, Caddy can’t bind to those ports because something else already has.

As for how that’s possible when netstat is empty… I’m stumped, personally. Apart from Caddy, is this a stock Ubuntu? Do you have any other software on there?

I don’t have any other webservers unless they were installed in the upgrade process somehow. After I upgraded I tried apt remove nginx and for Apache and stuff but those didn’t seem to be installed. I have no idea what would be using those ports.

Alright turns out I’m really dumb, the upgrade did install Apache2 which was interfering with Caddy. Thanks for your help.

1 Like

Hah! Thanks Canonical!

Glad to hear it’s resolved.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.