Skip to content

fix(config): ignore ambient HOSTNAME that echoes the machine hostname - #184

Merged
gbasin merged 1 commit into
gbasin:masterfrom
0x79H:fix/hostname-env-collision
Aug 2, 2026
Merged

fix(config): ignore ambient HOSTNAME that echoes the machine hostname#184
gbasin merged 1 commit into
gbasin:masterfrom
0x79H:fix/hostname-env-collision

Conversation

@0x79H

@0x79H 0x79H commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #183

Containers and some CI runner images auto-export HOSTNAME=<machine hostname>, and config.ts reads HOSTNAME as the bind address — so in those environments the server silently binds to the machine hostname instead of localhost (full details and repro in #183).

Minimal guard: a HOSTNAME equal to os.hostname() is treated as ambient — a warning is logged (pointing at HOSTNAME=0.0.0.0 for anyone who does want non-localhost binding) and the default 127.0.0.1 is kept. Deliberate values keep working unchanged: 0.0.0.0, 127.0.0.1, any interface IP, and localhost are passed through as before (covered by tests).

Deliberately not included (see the issue): a dedicated variable name and/or restricting the value to IP literals — both are policy calls; happy to follow up either way.

Containers and some CI runner images auto-export HOSTNAME as the machine
name, which made the server silently bind away from localhost. Treat a
HOSTNAME equal to os.hostname() as ambient - warn and keep 127.0.0.1 -
while deliberate values like 0.0.0.0 or localhost keep working unchanged.
@gbasin

gbasin commented Aug 2, 2026

Copy link
Copy Markdown
Owner

lgtm

@gbasin
gbasin merged commit 19dc236 into gbasin:master Aug 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-exported HOSTNAME hijacks the bind address in containers

2 participants