Pact "Could not connect to broker" (PACT_BROKER_BASE_URL) in CI
Unlike a 401 or 404, this failure happens before any HTTP response: the client could not open a connection to the broker URL. The base URL is wrong or unset, or the broker is unreachable from the runner network.
What this error means
Publish or verify fails with "Could not connect to the Pact Broker", "getaddrinfo ENOTFOUND", or "Connection refused" for the broker base URL.
Pact
Error making request to https://acme.pactflow.io
Failed to open TCP connection to acme.pactflow.io:443
getaddrinfo: Name or service not knownCommon causes
PACT_BROKER_BASE_URL is unset or malformed
The variable is empty, missing the scheme, or has a typo, so the client cannot resolve or reach a valid host.
The broker is not reachable from the runner
A self-hosted broker behind a private network or firewall is not routable from the CI runner.
How to fix it
Set a correct, fully qualified base URL
- Set
PACT_BROKER_BASE_URLincluding thehttps://scheme. - Confirm the host resolves and responds from the runner.
- Re-run once connectivity is confirmed.
.github/workflows/ci.yml
env:
PACT_BROKER_BASE_URL: https://acme.pactflow.io
# quick reachability check from the runner:
# curl -sSf -o /dev/null "$PACT_BROKER_BASE_URL"Make a private broker reachable
For a self-hosted broker, put the runner on the same network or expose the broker to the CI environment.
How to prevent it
- Always set an absolute broker base URL including the scheme.
- Add a one-line reachability check before publish or verify.
- Ensure self-hosted brokers are routable from your runners.
Related guides
Pact Broker "401 Unauthorized" retrieving pacts in CIFix Pact "Error retrieving pacts: 401 Unauthorized" in CI - the broker request had no valid PACT_BROKER_TOKEN…
Pact Broker SSL "certificate verify failed" in CIFix Pact Broker TLS "SSL_connect ... certificate verify failed" in CI - the client could not validate the bro…
Pact Broker Docker container not ready before publish in CIFix a dockerized Pact Broker not being ready in CI - publish or verify runs before the pactfoundation/pact-br…