Caddy error listen tcp 127.0.0.1:2019: bind: cannot assign

前记

最近在使用 Caddy 的时候出现如下错误

1
2
3
4
5
6
7
8
9
10
Jan 05 02:16:47 C20230104172971 caddy[3271]: HOME=/root
Jan 05 02:16:47 C20230104172971 caddy[3271]: LOGNAME=root
Jan 05 02:16:47 C20230104172971 caddy[3271]: USER=root
Jan 05 02:16:47 C20230104172971 caddy[3271]: SHELL=/bin/sh
Jan 05 02:16:47 C20230104172971 caddy[3271]: INVOCATION_ID=91c06f7e038e4ed2a5e12d9d975650b1
Jan 05 02:16:47 C20230104172971 caddy[3271]: JOURNAL_STREAM=8:26524
Jan 05 02:16:47 C20230104172971 caddy[3271]: {"level":"info","ts":1672885007.9022179,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Jan 05 02:16:47 C20230104172971 caddy[3271]: run: loading initial config: loading new config: starting caddy administration endpoint: listen tcp 127.0.0.1:2019: bind: cannot assign>
Jan 05 02:16:47 C20230104172971 systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
Jan 05 02:16:47 C20230104172971 systemd[1]: caddy.service: Failed with result 'exit-code'.

解决

Caddyfile 开头增加下面配置即可

1
2
3
{
admin 0.0.0.0:2019
}