Back to Blog

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

  1. railway.com → your project
  2. Select the Postgres service
  3. Variables / Connect UI → public URI, or build from user/password/db + RAILWAY_TCP_PROXY_DOMAIN + RAILWAY_TCP_PROXY_PORT
  4. 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

  1. mcpserver.designConnectionsAddPostgreSQL
  2. Paste the public URI
  3. Name: Railway staging (honest names)
  4. TestSave → restrict tables if you want
  5. 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

  1. Claude → CustomizeConnectors
  2. Add custom connector
  3. Name: Synra Railway staging
  4. Paste Synra URL (token in URL = auth)
  5. 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: