Caddy starts up without issues on MacOS even if there is already another process listening on the same port.
Example:
# test1/Caddyfile
:80 {
respond "hello world server1"
}
# test2/Caddyfile
:80 {
respond "hello world server2"
}
Starting up server 1:
$ caddy run --config test1/Caddyfile
2024/08/12 11:58:43.773 INFO using config from file {"file": "test1/Caddyfile"}
2024/08/12 11:58:43.773 INFO adapted config to JSON {"adapter": "caddyfile"}
2024/08/12 11:58:43.775 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//[::1]:2019", "//127.0.0.1:2019", "//localhost:2019"]}
2024/08/12 11:58:43.775 WARN http.auto_https server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server {"server_name": "srv0", "http_port": 80}
2024/08/12 11:58:43.775 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc000676280"}
2024/08/12 11:58:43.775 INFO http.log server running {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2024/08/12 11:58:43.775 INFO autosaved config (load with --resume flag) {"file": "/Users/work/Library/Application Support/Caddy/autosave.json"}
2024/08/12 11:58:43.775 INFO serving initial configuration
2024/08/12 11:58:43.799 INFO tls storage cleaning happened too recently; skipping for now {"storage": "FileStorage:/Users/work/Library/Application Support/Caddy", "instance": "394620b5-a9e0-4018-b6c0-60875ef7ed91", "try_again": "2024/08/13 11:58:43.799", "try_again_in": 86399.999999331}
2024/08/12 11:58:43.800 INFO tls finished cleaning storage units
Starting up server 2:
$ caddy run --config test2/Caddyfile
2024/08/12 11:59:44.663 INFO using config from file {"file": "test2/Caddyfile"}
2024/08/12 11:59:44.664 INFO adapted config to JSON {"adapter": "caddyfile"}
2024/08/12 11:59:44.665 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2024/08/12 11:59:44.665 WARN http.auto_https server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server {"server_name": "srv0", "http_port": 80}
2024/08/12 11:59:44.665 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc00068b780"}
2024/08/12 11:59:44.665 INFO http.log server running {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2024/08/12 11:59:44.665 INFO autosaved config (load with --resume flag) {"file": "/Users/work/Library/Application Support/Caddy/autosave.json"}
2024/08/12 11:59:44.665 INFO serving initial configuration
2024/08/12 11:59:44.687 INFO tls storage cleaning happened too recently; skipping for now {"storage": "FileStorage:/Users/work/Library/Application Support/Caddy", "instance": "394620b5-a9e0-4018-b6c0-60875ef7ed91", "try_again": "2024/08/13 11:59:44.687", "try_again_in": 86399.999999446}
2024/08/12 11:59:44.687 INFO tls finished cleaning storage units
Sending a request is answered by server 1:
$ curl http://localhost
hello world server1%
Expected behaviour: Server 2 should not start up but throw an error, such as it does on Linux systems:
$ caddy run --config test2/Caddyfile
2024/08/12 11:56:25.354 INFO using config from file {"file": "test1/Caddyfile"}
2024/08/12 11:56:25.355 INFO adapted config to JSON {"adapter": "caddyfile"}
2024/08/12 11:56:25.356 INFO admin admin endpoint started {"address": ":2020", "enforce_origin": false, "origins": ["//:2020"]}
2024/08/12 11:56:25.356 WARN admin admin endpoint on open interface; host checking disabled {"address": ":2020"}
2024/08/12 11:56:25.356 WARN http.auto_https server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server {"server_name": "srv0", "http_port": 80}
2024/08/12 11:56:25.356 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc00072be80"}
2024/08/12 11:56:25.356 INFO tls.cache.maintenance stopped background certificate maintenance {"cache": "0xc00072be80"}
Error: loading initial config: loading new config: http app module: start: listening on :80: listen tcp :80: bind: address already in use
Caddy starts up without issues on MacOS even if there is already another process listening on the same port.
Example:
Starting up server 1:
Starting up server 2:
Sending a request is answered by server 1:
Expected behaviour: Server 2 should not start up but throw an error, such as it does on Linux systems:
Versions:
MacOS: 14.6.1