1. The problem I’m having:
I’m running Caddy server inside VM (host: Debian 12 + libvirt + qemu + guest: Debian 13). I assigned static ip address to VM in libvirt network conf and made script to forward ports that executes on VM start. Everything works fine if I run caddy when VM is booted already. When VM starts, caddy fails to run before I manually restart it. I want to figure out why is it happening.
I’ve already made changes in Caddyfile that solve the issue, but it’s not enough for me, cause I haven’t faced this issue before (when I played with caddy inside LXC containers some time ago). I want to assign local port to another app, binding caddy only to external address or vice versa.
2. Error messages and/or full log output:
Command: `sudo systemctl status caddy`
Output:
× caddy.service - Caddy
Loaded: loaded (/usr/lib/systemd/system/caddy.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Mon 2025-09-01 00:06:32 MSK; 1min 19s ago
Invocation: 52d6636b1ff4422cb37cac961d7c35b8
Docs: https://caddyserver.com/docs/
Process: 694 ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile (code=exited, status=1/FAILURE)
Main PID: 694 (code=exited, status=1/FAILURE)
Status: "loading new config: http app module: start: listening on 192.168.120.20:443: listen tcp 192.168.120.20:443: bind: cannot assign requested address"
Mem peak: 49.8M
CPU: 94ms
Sep 01 00:06:32 entry-guest caddy[694]: {"level":"info","ts":1756674392.4919827,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//>
Sep 01 00:06:32 entry-guest caddy[694]: {"level":"info","ts":1756674392.492658,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00002b280"}
Sep 01 00:06:32 entry-guest caddy[694]: {"level":"info","ts":1756674392.4964783,"logger":"http.auto_https","msg":"automatic HTTPS is completely disabled for server","server_name":"srv0"}
Sep 01 00:06:32 entry-guest caddy[694]: {"level":"info","ts":1756674392.4967372,"logger":"tls.cache.maintenance","msg":"stopped background certificate maintenance","cache":"0xc00002b280"}
Sep 01 00:06:32 entry-guest caddy[694]: {"level":"info","ts":1756674392.4967535,"logger":"http","msg":"servers shutting down with eternal grace period"}
Sep 01 00:06:32 entry-guest caddy[694]: {"level":"info","ts":1756674392.496955,"msg":"maxprocs: No GOMAXPROCS change to reset"}
Sep 01 00:06:32 entry-guest caddy[694]: Error: loading initial config: loading new config: http app module: start: listening on 192.168.120.20:443: listen tcp 192.168.120.20:443: bind: cannot >
Sep 01 00:06:32 entry-guest systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
Sep 01 00:06:32 entry-guest systemd[1]: caddy.service: Failed with result 'exit-code'.
Sep 01 00:06:32 entry-guest systemd[1]: Failed to start caddy.service - Caddy.
3. Caddy version:
v2.10.2
4. How I installed and ran Caddy:
From Caddyserver official page for Debian users. Using apt package manager. Run as a systemd service.
a. System environment:
OS: Host - Debian 12, Guest - Debian 13
Arch: amd64
virsh version output:
Using library: libvirt 9.0.0
Using API: QEMU 9.0.0
Running hypervisor: QEMU 7.2.17
libvirt network xml:
<network connections="2">
<name>default</name>
<uuid>HIDDEN</uuid>
<forward mode="nat">
<nat>
<port start="1024" end="65535"/>
</nat>
</forward>
<bridge name="virbr0" stp="on" delay="0"/>
<mac address="HIDDEN"/>
<dns enable="no"/>
<ip address="192.168.120.1" netmask="255.255.255.0">
<dhcp>
<range start="192.168.120.2" end="192.168.120.254"/>
<host mac="HIDDEN" ip="192.168.120.10"/>
<host mac="HIDDEN" ip="192.168.120.20"/> <!-- caddy -->
</dhcp>
</ip>
</network>
b. Command:
# How I run caddy
sudo systemctl start caddy
# How I check caddy's status
sudo systemctl status caddy
c. Service/unit/compose file:
Default systemd unit file, hasn’t been changed.
d. My complete Caddy config:
Config that causes error (response is for testing purposes):
{
servers 192.168.120.20:443 {
listener_wrappers {
proxy_protocol {
fallback_policy use
}
tls
}
protocols h2 h1
}
}
https://example.com:443 {
bind 192.168.120.20
tls /etc/caddy/cert.crt /etc/caddy/key.key
header Content-Type text/html
respond * 200 {
body <<HTML
<html>
<head><title>Respond</title></head>
<body>
<div style="padding-top:80px;font-size:28px;">
<h2 style="text-align:center;">Remote Host: {remote_host}</h2>
<h2 style="text-align:center;">Remote Port: {remote_port}</h2>
<h2 style="text-align:center;">Client IP: {client_ip}</h2>
</div>
</body>
</html>
HTML
}
}
Config that doesn’t have issues:
{
servers :443 {
listener_wrappers {
proxy_protocol {
fallback_policy use
}
tls
}
protocols h2 h1
}
}
https://example.com {
tls /etc/caddy/cert.crt /etc/caddy/key.key
header Content-Type text/html
respond * 200 {
body <<HTML
<html>
<head><title>Respond</title></head>
<body>
<div style="padding-top:80px;font-size:28px;">
<h2 style="text-align:center;">Remote Host: {remote_host}</h2>
<h2 style="text-align:center;">Remote Port: {remote_port}</h2>
<h2 style="text-align:center;">Client IP: {client_ip}</h2>
</div>
</body>
</html>
HTML
}
}