Unable to use DNS challenge ( tcp :80: bind: address already in use )


(Rishav Kundu) #1

I have an example Caddyfile:

files.example.org {
    tls {
          dns cloudflare
   }
}

I supplied the CLOUDFLARE_EMAIL and CLOUDFLARE_API_KEY environment variables and downloaded the version of caddy with the plugin. Yet, I am receiving an error that caddy was unable to bind to port 80.

I thought using the DNS challenge meant that port 80 wouldn’t be required?


(Matthew Fay) #2

With your configuration, Caddy doesn’t need port 80 for certificate validation, no - but it’ll still try to serve your site on the standard HTTP and HTTPS ports, 80 and 443.

If you want it to use something different, you can specify scheme/port combinations Caddy should listen on in the site labels, e.g:

http://files.example.org:8080,
https://files.example.org:8443 {
  tls {
    dns cloudflare
  }
}

(Rishav Kundu) #3

Is it possible to disable this http->https redirect altogether? It seems ungainly to have to specify a random HTTP port I am never going to use.


(Rishav Kundu) #4

This did not work for me, but specifiying -http-port on the CLI did.


(Matthew Fay) #5

I’m not sure why or how that wouldn’t work, unless there were other entries in your Caddyfile, but I’m glad you’ve got a working solution.

Automatic HTTPS is the feature responsible for the default HTTP->S redirect. You can override it by defining your own HTTP listener for the site in question (e.g. http://example.com), or alternatively disabling Automatic HTTPS.