Unable to connect to PgBouncer via private URL within same project
sagun-m
FREEOP

a month ago

I am trying to add PgBouncer to proxy all database calls in my Railway project.

Project setup: The App, PgBouncer service, and the PostgreSQL database are all in the same project and same environment.

Goal: Route all database calls through PgBouncer to benefit from connection pooling.

Issue:

When I try to connect to PgBouncer using the private internal URL, I get the following error:

```

ConnectionRefusedError: [Errno 111] Connect call failed ('fd12:1987:6b3a:0:5000:10:171b:340d', 6432, 0, 0)

```

The connection string I am using is:

```

postgresql+asyncpg://<username>:<password>@compassionate-alignment.railway.internal:6432/<database>

```

Observations:

Connecting from other images/services in the project works fine using their respective private URLs.

Connecting directly to PostgreSQL 5432) also works internally.

The error appears only when connecting to the PgBouncer image via the private URL.

Steps taken:

1. Verified credentials and ports.

2. Verified that PostgreSQL is reachable internally.

3. Attempted connections using psql and async SQLAlchemy clients.

Request:

Help understand why the private URL to PgBouncer is refusing connections within the same project environment and how to properly configure internal connectivity for PgBouncer in Railway?

Attachments

Solved$10 Bounty

Pinned Solution

darseen
HOBBYTop 5% Contributor

a month ago

Your error shows the client is attempting to connect via IPv6 (fd12:1987:6b3a:0:5000:10:171b:340d), but PgBouncer is likely configured to listen only on IPv4. You need to configure PgBouncer to listen on all interfaces especially IPv6.

1 Replies

darseen
HOBBYTop 5% Contributor

a month ago

Your error shows the client is attempting to connect via IPv6 (fd12:1987:6b3a:0:5000:10:171b:340d), but PgBouncer is likely configured to listen only on IPv4. You need to configure PgBouncer to listen on all interfaces especially IPv6.


Status changed to Solved noahd about 1 month ago


Loading...