Why is caddy trying to start on port 80?

1. My Caddy version (caddy -version):

v2.0.0-beta.13 h1:QL0JAepFvLVtOatABqniuDRQ4HmtvWuuSWZW24qVVtk=

2. How I run Caddy:

./caddy run Caddyfile

a. System environment:

Ubuntu 18.04

b. Command:

./caddy run Caddyfile

d. My complete Caddyfile:

        #
        # hass
        #
        http://hass.lcl.info:9999 {
            reverse_proxy / http://172.18.0.5 {
            }
        }

3. The problem I’m having:

Caddy tries to start on port 80 despite not having anything to serve on that port.

Alternatively, it may want to start on port 80 to provide a Let’s Encrypt challenge endpoint but there are not HTTPS services in the Caddyfile

4. Error messages and/or full log output:

2020/01/23 13:39:39.260 INFO    using adjacent Caddyfile
2020/01/23 13:39:39.262 INFO    admin   admin endpoint started  {"address": "localhost:2019", "enforce_origin": false, "origins": ["localhost:2019"]}
2020/01/23 13:39:39.262 INFO    http    enabling automatic HTTP->HTTPS redirects        {"server_name": "srv0"}
2020/01/23 13:39:39.263 INFO    http    enabling automatic TLS certificate management   {"domains": ["hass.lcl.info"]}
2020/01/23 14:39:39 [INFO][cache:0xc0003b3e00] Started certificate maintenance routine
run: loading initial config: loading new config: http app module: start: tcp: listening on :80: listen tcp :80: bind: address already in use

That looks like a bug. Would you please file an issue on GitHub so I can fix it? Thanks for using Caddy 2 while it’s still in beta!

1 Like

@matt: done (Caddy trying to start on port 80 without any HTTPS sites defined · Issue #2998 · caddyserver/caddy · GitHub)

1 Like

Thanks – for anyone following along at home, I pushed a commit here: httpcaddyfile: Skip hosts from auto-https when http:// scheme (fix #2… · caddyserver/caddy@8b2ad61 · GitHub - which should fix it.

Edit: For everyone finding this in search results, you’re probably seeing Caddy trying to redirect HTTP to HTTPS, which requires the HTTP port (80); not this particular bug, which is where Caddy was trying to use port 80 even without an HTTPS site.

1 Like

Thank you very much @matt .

@matt, This issue seems to be happening again. I’m trying to start localhost:16655

caddyfile.json

{
  "logging": {
    "logs": {
      "log0": {
        "writer": {
          "filename": "d:\\caddy\\access564.log",
          "output": "file"
        },
        "include": [
          "http.log.access.log0"
        ]
      }
    }
  },
  "apps": {
    "http": {
      "servers": {
        "srv0": {
          "listen": [
            ":16655"
          ],
          "routes": [
            {
              "match": [
                {
                  "host": [
                    "localhost"
                  ]
                }
              ],
              "handle": [
                {
                  "handler": "subroute",
                  "routes": [
                    {
                      "handle": [
                        {
                          "body": "this is a caddy2 server",
                          "handler": "static_response"
                        }
                      ]
                    }
                  ]
                }
              ],
              "terminal": true
            }
          ],
          "logs": {
            "logger_names": {
              "localhost:16655": "log0"
            }
          }
        }
      }
    }
  }
}

load and response

D:\caddy>curl localhost:2019/load -X POST -H "Content-Type: application/json" -d @caddyfile.json
{
  "error": "loading config: loading new config: http app module: start: tcp: listening on :80: listen tcp :80: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."
}

You’re hitting the local Auto HTTPS rules, it’s trying to set up an HTTP->HTTPS redirect for you.

Use the global option http_port to change it to some other port or turn off automatic redirects JSON Config Structure - Caddy Documentation

1 Like

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