Skip to main content
Railway gives a Postgres service two addresses, and the one it shows you first is the one that won’t work from outside Railway. That’s the whole difficulty here; everything else is standard. Once connected, your agent reaches Railway only through Midplane: every statement is parsed, checked against policy, and written to the audit trail before it runs.

The internal hostname won’t work

Railway’s DATABASE_URL points at the private network:
*.railway.internal resolves only from services inside the same Railway project, on Railway’s private IPv6 network. It doesn’t resolve from your laptop, and it doesn’t resolve from Midplane Cloud. Private address space is rejected before a connection is attempted, so Test connection reports:
You have two ways forward, depending on whether you want the database exposed at all.

Option 1 — expose a TCP proxy

Railway databases are private by default. To reach one from outside, open the Postgres service’s Settings → Networking and add Public Networking. Railway creates a TCP proxy and populates a second variable:
Use that value — the host and port are assigned by Railway, so copy it from the service’s Variables rather than assembling one by hand. Add sslmode=require and paste it into Connect Postgres in the dashboard.
A TCP proxy is a public listener. Anyone with the credential can reach the database, so this is the moment to stop using the default postgres superuser and create the least-privilege role below.

Option 2 — run Midplane inside the project

If you’d rather not expose the database at all, self-host Midplane as a service in the same Railway project. The internal hostname then resolves normally, the database stays private, and your agents connect to Midplane’s endpoint instead of to Postgres. This keeps the number of publicly reachable things at one, and the thing that’s public is the layer that parses SQL and enforces policy — rather than the database itself.

Create a least-privilege role

Railway hands you the postgres superuser. Connect once with it and create a role for Midplane:
Then swap the username and password in the connection string you copied. Leave Midplane’s default access level at read and grant writes per table later — see table access.

Next steps

Connect your agent

Wire up Cursor, Claude Code, or any MCP client.

Write a policy

Grant the reads and writes your agent actually needs.