How to Connect Claude to Railway Postgres with MCP
Connect Claude to Railway PostgreSQL via MCP. Use the public TCP proxy URL (not railway.internal), Synra endpoint into Claude connectors, staging vs production environments.
Railway runs Postgres next to the app. Claude asks what the data means. Common failure: paste the private DATABASE_URL into a hosted gateway and wonder why it dies.
Synra is outside Railway — it needs the public TCP proxy URL. Claude path below. Cursor: Connect Cursor to Railway Postgres. Any host: Connect Claude to PostgreSQL.
Also: staging first, SELECT-only user.
Private vs public (don’t skip)
| URL | Host shape | Synra? |
|-----|------------|--------|
| Private | Postgres.railway.internal | No |
| Public / TCP proxy | *.proxy.rlwy.net + high port | Yes |
App services should keep using private networking. Claude’s gateway should not. Details: Railway private networking, TCP proxy.
Egress through the proxy is billable; AI volume is usually small — still don’t schedule heavy scans on huge prod tables for fun (weekly reports).
Step 1 — Public connection string
- railway.com → your project
- Select the Postgres service
- Variables / Connect UI → public URI, or build from user/password/db +
RAILWAY_TCP_PROXY_DOMAIN+RAILWAY_TCP_PROXY_PORT - Pick the environment first (staging vs production)
postgresql://postgres:PASSWORD@HOST.proxy.rlwy.net:PORT/railway
Host must not be railway.internal.
Step 2 — Synra
- mcpserver.design → Connections → Add → PostgreSQL
- Paste the public URI
- Name:
Railway staging(honest names) - Test → Save → restrict tables if you want
- Copy MCP endpoint from Endpoints
If test fails: private URL pasted, password needs URL-encoding, or TCP proxy off — enable under Postgres networking.
Step 3 — Claude custom connector
- Claude → Customize → Connectors
- Add custom connector
- Name:
Synra Railway staging - Paste Synra URL (token in URL = auth)
- Confirm tools:
list_tables,describe_table,query_table,execute_sql
Menus move; look for custom / MCP / developer connectors. Stuck? MCP troubleshooting.
Step 4 — Smoke test
- “List tables.”
- “Describe
users/profiles— whichever exists.” - “Count rows in the main business table.”
- A deliberate
UPDATE … WHERE false→ should fail
Verify. Check Usage that the credential name is the staging one.
Railway habits
- One Synra connection per Railway environment
- App
DATABASE_URL(private) ≠ Synra URI (public) - Password rotate on Railway → update Synra, re-test
- Share endpoints carefully (team sharing)
- Need prod-shaped freshness later → replica if you have one, not casual primary
Same endpoint in Cursor
One Synra URL works in Cursor too. Separate endpoints for staging vs production — don’t rename a staging connection after pointing it at prod variables.
Public Railway URI into Synra, endpoint into Claude, known-answer question first.
7-day trial: mcpserver.design.
Related reading:
- Connect Cursor to Railway Postgres — same DB, Cursor
- Connect Claude to PostgreSQL — any Postgres host
- Connect Claude to Neon — branch-oriented Neon
- Connect Claude to Supabase — RLS / service role
- Check a Migration Against Your Database With AI — once connected
- Explore an Unfamiliar Database With AI — schema tour prompts