{
  "id": 21069819,
  "title": "My --config-test accepted a listen address that could never bind",
  "url": "https://urgent.news/2026/11/21/my-config-test-accepted-a-listen-address-that-could-never-bind",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-21T16:08:12.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/marcusbeauregard/my-config-test-accepted-a-listen-address-that-could-never-bind-51o6"
  },
  "original_language": "en",
  "account": "transponder is a Go proxy that the author has been developing. The proxy includes a --config-test flag, which loads the configuration, validates it, and exits with a status code of 0 or 1. This flag is utilized in CI tests and the deployment script before any server starts. Last week, a configuration passed the --config-test, yet the server crashed just 200 milliseconds later with the error: \"listen tcp: lookup tcp/nope: unknown port\". The configuration contained the line \"listen_addr: \":nope\"\". The author's verification process involved using the net.SplitHostPort function, followed by strconv.Atoi and range checking. Despite feeling correct due to the standard library handling the parsing, net.SplitHostPort merely splits the string without validating it. The author examined the outcomes of SplitHostPort against various inputs, such as \":nope\", \":70000\", and \"+80\", finding that each value splits correctly. However, net.Listen behaves differently for these inputs, with \":nope\" resulting in \"listen tcp: lookup tcp/nope: unknown port\", while \":70000\" leads to \"listen tcp: address 70000: invalid port\". The port needs to be processed similarly to how net.Listen processes it, which involves checking if the number is within the range 0-65535 or resolving the service name using net.LookupPort. The author also discussed the two-listener case, where the main listener and ops listener sharing the same port causes a startup failure. Comparing hosts is done by comparing net.IP.Equal, considering case folding, and separating zones due to the limitations of net.ParseIP. The author introduced a wildcard rule, stating that an unspecified address should not be used in conjunction with any host on the same port. They discovered a discrepancy between the author's mental model and the behavior of net/ipsock_posix.go, where 0.0.0.0 claims both IPv4 and IPv6 addresses. To prevent this, the author adopted a conservative rule: any unspecified host conflicting with anything on that port. The author also addressed the issue of zones, noting that net.ParseIP ignores zones, causing conflicts between interfaces with the same zone. The final rule emphasizes that a configuration check should reflect the consumer's processing of values, including the same parser, edge cases, and refusals. Otherwise, it becomes a linter with a --config-test label, approving the file while the process still fails, leading to an error message lacking the specific key that caused the issue.",
  "summary": "transponder is a Go proxy I've been building. It has a --config-test flag: load the config, validate it, exit 0 or 1. It runs in CI and in the deploy script before anything starts. Last week a config passed --config-test and the server died 200 ms later with: listen tcp: lookup tcp/nope: unknown port No key name, no line number, nothing to grep for. The config had listen_addr: \":nope\" . The check…",
  "key_points": [
    "Configuration test passed despite invalid listen address \":nope\"",
    "Server crashed 200ms after passing --config-test",
    "Author added rule to reject unspecified addresses with same port"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}