postgres.railway.internal
resolves only for Railway services. This guide opens a TCP proxy so the
gateway can reach it from your computer or a server. You need a Midplane
project (get started).
1
Turn on public networking
Open the Postgres service’s Settings, then Networking, and add
Public Networking. Railway creates a TCP proxy and a variable,
DATABASE_PUBLIC_URL, with its host and port.2
Create a role for the gateway
Open a SQL shell on the database, such as with The proxy is reachable from the internet, so give the gateway this role,
never the
railway connect Postgres
from the Railway CLI. Replace the placeholder and run:postgres superuser. This role can only read. To let agents
write, see letting agents write.3
Give setup the connection string
Take the host and port from Railway’s Postgres makes its own certificate, which no CA signs, so the
gateway can’t check it:
DATABASE_PUBLIC_URL:no-verify encrypts the connection without that
check. Put the line after its MIDPLANE_DSN_…= in the env file, or
paste it when midplane setup asks for the connection string (deploy
the gateway).4
Check that it connects
Setup says
ok with the database and its number of tables. Once the
gateway runs, Test connection on the Gateways page shows your
database’s id with ok, such as shop ok, 3 ms, and the policy
editor lists your tables.