5 hours ago
Hello Railway team,
I am developing a small application on Railway's Hobby plan, using an ASP.NET Core backend and a PostgreSQL 16 database in the same private project environment.
The database is accessed exclusively through private networking, with TLS certificate verification, SCRAM-SHA-256 authentication and a dedicated least-privilege database role.
Currently, PostgreSQL restricts backend access through a single private IPv6 address in pg_hba.conf. However, the backend's private source address can change between deployments.
I would like to establish a secure and reliable configuration that does not require manual updates to pg_hba.conf after every deployment.
- Service-specific hostname authentication
Does Railway guarantee that the actual private source IP address of a backend connection can be reverse-resolved from the PostgreSQL container to the backend's stable, service-specific internal hostname?
Does forward resolution of that hostname also include the original client IP address, as required by PostgreSQL hostname-based HBA authentication?
Does this remain supported during:
Regular deployments and overlapping deployments?
Service restarts?
Replica changes?
Host or region migrations?
IPv4 and IPv6 address selection?
Are there documented DNS TTLs or propagation guarantees relevant to this use case?
- Alternative private network restrictions
If reliable service-specific reverse and forward DNS resolution is not supported:
Does Railway provide a documented, stable and environment-exclusive private CIDR range that covers all possible backend source addresses?
Does Railway offer stable private service IP addresses?
Are native service-to-service network access policies available on the Hobby plan?
- Recommended architecture
What is Railway's recommended approach for securely restricting PostgreSQL access to an application backend when its private source IP address may change between deployments?
I am specifically looking for a private networking solution without exposing PostgreSQL publicly or using public static outbound IP addresses.
Please clarify which properties are officially supported or guaranteed, and whether any additional plan or resource costs would apply.
Thank you for your assistance.
3 Replies
5 hours ago
We can't confirm reverse DNS (PTR) lookups for private source addresses, or a matching forward lookup, as a supported property. The same goes for stable private service IPs, a fixed per-environment private address range, published internal DNS TTLs, and service-to-service access policies. We wouldn't recommend building pg_hba.conf rules on any of them.
What we can confirm: every service gets an internal hostname, <service-name>.railway.internal, which resolves to that service's current internal addresses. Environments created after October 16, 2025 get IPv4 and IPv6 addresses. Older environments get IPv6 only.
The private network is isolated per project and per environment. Services in other projects or environments can't reach your database over it, and traffic between services is encrypted with Wireguard.
Since the private network is already scoped to your project environment, your access control can rest on the controls you already have: TLS, SCRAM-SHA-256 and the least-privilege role. An HBA rule that accepts your environment's private traffic doesn't need updating after each deployment, unlike a single source address. Private traffic doesn't count toward egress billing, so this setup adds no networking cost on the Hobby plan.
More detail is in our private networking docs.
Status changed to Awaiting User Response Railway • about 5 hours ago
22 minutes ago
Thank you for the clarification. This is very helpful.
We would like to follow your recommended architecture using Railway's private environment isolation, TLS VerifyFull, SCRAM-SHA-256 and a least-privilege PostgreSQL role.
There is one remaining implementation question:
Since Railway does not guarantee a fixed per-environment private CIDR range, what exact source-address configuration in PostgreSQL's pg_hba.conf do you recommend for accepting private connections independently of backend IP changes?
Should PostgreSQL rely entirely on Railway's private network isolation for source restrictions, provided that no public TCP proxy or other public database endpoint exists?
Are there any additional considerations for IPv6-only or dual-stack environments?
We want to avoid relying on undocumented private address ranges while following Railway's recommended security architecture.
Thank you!
Status changed to Awaiting Railway Response Railway • 22 minutes ago
21 minutes ago
Since we don't publish a fixed private address range for your environment, the source-address field shouldn't depend on one. Using all as the address in a hostssl line, limited to your database name and dedicated role with scram-sha-256, matches the setup our earlier reply described. Add a hostssl ... reject line after it for all other roles and databases, so nothing else is accepted.
Yes, with that setup the source restriction comes from private network isolation. Each environment has its own isolated network, so services in other projects or environments can't reach your database over it. Any service in the same environment is inside that boundary, so TLS VerifyFull, SCRAM and the least-privilege role do the access control. This only holds while no TCP proxy or other public endpoint is attached to the database.
For IPv6-only and dual-stack environments, make sure PostgreSQL listens on both address families (for example listen_addresses = '*'), because environments created before October 16, 2025 have IPv6 private addresses only. An all address entry covers both IPv4 and IPv6 sources. Your backend should connect using the .railway.internal hostname, not a literal IP address.
Status changed to Awaiting User Response Railway • 21 minutes ago