Dredd "connect ECONNREFUSED" against the API in CI
Dredd validated your API description against a live server, but the server was not accepting connections at the endpoint you passed. In CI the server is usually starting in the same job and Dredd runs before its port is open.
What this error means
Dredd fails every transaction with "Error connecting to server under test!" and "connect ECONNREFUSED 127.0.0.1:3000", exiting non-zero.
error: Error connecting to server under test!
error: connect ECONNREFUSED 127.0.0.1:3000Common causes
The server was not ready when Dredd started
Dredd runs before the API binds its port, so the connection is refused for every transaction.
Wrong endpoint host or port
The endpoint argument points at a host or port the app does not listen on in CI.
How to fix it
Let Dredd start and wait for the server
- Use Dredd's server and wait options so it launches the app and waits.
- Or poll a health endpoint before invoking Dredd.
- Confirm the endpoint matches the app host and port.
dredd apiary.apib http://127.0.0.1:3000 \
--server "npm start" --server-wait 15Poll readiness in the workflow
Start the server, wait for a health endpoint, then run Dredd so it never connects too early.
until curl -sf http://127.0.0.1:3000/health; do sleep 2; done
dredd apiary.apib http://127.0.0.1:3000How to prevent it
- Use --server and --server-wait or a health poll before Dredd runs.
- Match the endpoint to the app host and port exactly.
- Gate the job on service readiness.