18

Caddy server would not start and displayed this error after upgrading to v0.9.3:

listen tcp :443: bind: permission denied

I was running caddy with systemd as user caddy. I checked that the binary was, in fact, owned by caddy.

ki9
  • 1,243
  • 1
  • 13
  • 19

2 Answers2

29

It's not a caddy issue, nor a user-permissions issue. Linux doesn't allow processes to listen on low-level ports by default.

To grant access:

sudo setcap CAP_NET_BIND_SERVICE=+eip $(which caddy)

source: superuser: Allow non-root process to bind to port 80 and 443?

ki9
  • 1,243
  • 1
  • 13
  • 19
12

If you're running systemd v229 or later, you can do this without giving the binary capabilities intrinsically:

AmbientCapabilities=CAP_NET_BIND_SERVICE
Dessa Simpson
  • 539
  • 7
  • 27
  • The [caddy systemd example config](https://github.com/mholt/caddy/blob/master/dist/init/linux-systemd/caddy.service) also mentions using `CapabilityBoundingSet=CAP_NET_BIND_SERVICE`. – ki9 Aug 28 '18 at 19:41