fix(gateway): bind to IPv6 dual-stack for Railway private networking - #227
Merged
Conversation
Railway's private networking (`*.railway.internal`) resolves to IPv6 addresses. The default `0.0.0.0` bind is IPv4-only and rejects internal service-to-service connections with ECONNREFUSED — observed when the web service proxies /mcp, /v1/*, etc. to the gateway via the single-origin rewrites added in ADR 0009. Binding to `::` (IPv6 unspecified) enables dual-stack mode, accepting both IPv4 and IPv6 traffic through the same socket. Public ingress (Railway edge → container) keeps working; docker-compose and local `pnpm dev` are unaffected because loopback works on both stacks.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After #226 (single-origin gateway) shipped, production hit
ECONNREFUSEDwhen the web service tried to proxy/mcp,/v1/*, etc. to the gateway over Railway's private network.Root cause: Railway's private DNS (e.g.
gateway.railway.internal) resolves to IPv6 addresses.@hono/node-server's default bind is0.0.0.0which is IPv4-only, so internal traffic was rejected even though public ingress worked.Fix
One-line change in apps/gateway/src/main.ts — pass
hostname: '::'toserve(). This binds the gateway in IPv6 dual-stack mode, which accepts BOTH IPv4 and IPv6 connections through the same socket on Linux. No other change needed.What's unaffected
gateway:8080inside the compose network already worked over IPv4; it now also works over IPv6 (which compose doesn't use, but harmless).pnpm dev: loopback on::1and127.0.0.1both reach the gateway.Test plan
pnpm -F @holo/gateway typecheck— cleanWEB_BASE_URL=https://holobase.dev pnpm verify:gatewayreturns 6 green checkshttps://holobase.dev/mcpround-trips (the operator gate from ADR 0009)🤖 Generated with Claude Code