Skip to content

Connect Railway Postgres to Infograph

What it brings in: Every table and view the user can read.

What you need

  • A Railway project with a Postgres service.
  • Access to the service's Settings and Variables tabs.

Your connection string

Each part is one thing you fill in, and each can fail on its own.

Railway Postgres· Connection string
postgresql://:@[name].proxy.rlwy.nethost: fix for "We couldn't find that host. Check the host name, then try again.":[port]port: fix for "The host refused the connection. Check the port, and that your database accepts connections from Infograph's address."/railwaydatabase: fix for "That database does not exist on this server."
AddressSign inDatabaseSelect a label for its fix

Steps

  1. Turn on public access

    Open your Postgres service, go to Settings, then Networking, and add Public Access. Railway creates a TCP Proxy with its own host and port.

  2. Create a read-only user

    Infograph only reads. Give it its own user so you can see and revoke its access in one place. Run this as the postgres user, in the Data tab or psql, with your own password and database name. Then use the new user and password in the string.

    CREATE USER infograph WITH PASSWORD '[strong-password]';
    GRANT CONNECT ON DATABASE [database] TO infograph;
    GRANT USAGE ON SCHEMA public TO infograph;
    GRANT SELECT ON ALL TABLES IN SCHEMA public TO infograph;
    ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO infograph;
  3. Copy the public connection string

    Open Variables and copy DATABASE_PUBLIC_URL. If you use Railway's PgBouncer template, copy DATABASE_PUBLIC_UNPOOLED_URL instead, since DATABASE_PUBLIC_URL then points at the pooler, which breaks syncing.

    postgresql://postgres:[password]@[name].proxy.rlwy.net:[port]/railway
  4. Paste it in Infograph and choose your tables

    Open Railway Postgres in Infograph, paste the string and press Connect. Pick the tables you want and Infograph starts loading them.

    Allow 51.222.152.247 through your firewall so Infograph can connect.

    Connect

Troubleshooting

Each entry is the message Infograph shows when a connection fails. Open it for the fix.

This host is not reachable from Infograph. Use your database's public address.

The host ends in .railway.internal, which only other Railway services can reach. Add Public Access under Settings, Networking and copy DATABASE_PUBLIC_URL instead.

We couldn't find that host. Check the host name, then try again.

Copy DATABASE_PUBLIC_URL again from Variables rather than typing it. If you removed and re-added Public Access, the proxy host changed.

The host refused the connection. Check the port, and that your database accepts connections from Infograph's address.

Railway's proxy uses its own random port, not 5432. Copy the whole DATABASE_PUBLIC_URL again so the port matches.

The server closed the connection. Check that it allows Infograph's address, and whether it requires an encrypted connection.

The server answered, then hung up before Infograph could sign in. Check it allows 51.222.152.247: some hosts close the connection rather than refuse it. If the server accepts only encrypted connections, set SSL Mode to Require under Advanced.

The host did not answer in time. Check the host and port, and that your firewall allows Infograph's address.

Check Public Access is still on under Settings, Networking, and that the port in the string is the proxy's port. A Postgres service that is stopped or redeploying cannot answer.

The username or password was not accepted.

Copy the string again from Variables, since Railway keeps the current password there. Characters such as @, # or / must be percent-encoded, so @ becomes %40.

Those credentials were not accepted.

Copy the string again from Variables. If you created a read-only user, check its name and password in the string.

That database does not exist on this server.

Copy DATABASE_PUBLIC_URL again so the name after the last / is exact. It is usually railway.