Skip to content

Commit 2ea44a3

Browse files
committed
forge: HTTP_ADDR=127.0.0.1 so WSL2 forwards to Windows localhost
gitea/forgejo's net.Listen("tcp", "0.0.0.0:3000") path internally upgrades to AF_INET6 dual-stack (`*:3000` in ss output), and WSL2's NAT-mode localhostForwarding does not forward dual-stack binds. Switching to HTTP_ADDR=127.0.0.1 forces gitea to call net.Listen with an IPv4 literal, producing an AF_INET socket that WSL2 forwards to Windows-side 127.0.0.1:3000. Verified live 2026-05-11 -- Windows TcpClient.ConnectAsync 127.0.0.1:3000 returns OK after the env flip. Trade-off: LAN-side reach from a phone or second laptop loses gitea (the listener is now loopback-only inside the VM). The follow-up will add a socat 0.0.0.0:3000 -> 127.0.0.1:3000 bridge service so LAN access comes back without re-introducing the dual- stack listener that broke Windows-side.
1 parent a19f9f4 commit 2ea44a3

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

etc/containers/systemd/mios-forge.container

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,21 @@ Environment=USER_GID=${MIOS_FORGE_GID:-816}
6767
# wanting richer config can drop a custom app.ini under /etc/mios/forge/
6868
# and add Environment=FORGEJO_APP_INI_PATH=/etc/mios/forge/app.ini.
6969
Environment=FORGEJO__server__ROOT_URL=http://localhost:${MIOS_PORT_FORGE_HTTP:-3000}/
70-
Environment=FORGEJO__server__HTTP_ADDR=0.0.0.0
70+
# 127.0.0.1, NOT 0.0.0.0. gitea/forgejo's net.Listen("tcp",
71+
# "0.0.0.0:3000") path internally upgrades to AF_INET6 dual-stack
72+
# (`*:3000` in ss output, AF_INET6-with-V6ONLY=0). WSL2 NAT-mode
73+
# localhostForwarding only catches AF_INET binds; AF_INET6 dual-
74+
# stack listens silently miss the forwarder and Windows times out
75+
# on 127.0.0.1:3000. Forcing HTTP_ADDR=127.0.0.1 makes gitea bind
76+
# AF_INET on 127.0.0.1:3000 explicitly, which WSL2 forwards.
77+
# Operator-flagged 2026-05-11 (`localhost:3000 timed out` after
78+
# searxng+cockpit IPv4 fixes were in).
79+
# Trade-off: LAN-side reach (phone, second laptop) needs an extra
80+
# socat hop or Windows-side netsh portproxy from the host's LAN IP
81+
# to the dev VM's NAT IP. Tracked separately; Windows-localhost
82+
# access is the higher-volume use case so that wins for the default.
83+
Environment=FORGEJO__server__HTTP_ADDR=127.0.0.1
84+
Environment=GITEA__server__HTTP_ADDR=127.0.0.1
7185
Environment=FORGEJO__server__HTTP_PORT=${MIOS_PORT_FORGE_HTTP:-3000}
7286
Environment=FORGEJO__server__SSH_PORT=${MIOS_PORT_FORGE_SSH:-2222}
7387
Environment=FORGEJO__server__SSH_LISTEN_HOST=0.0.0.0

0 commit comments

Comments
 (0)