{"schemaVersion":"1.0","canonicalUrl":"https://automationtester.in/failures/econnrefused-in-ci","slug":"econnrefused-in-ci","title":"ECONNREFUSED in CI","signature":"Error: connect ECONNREFUSED 127.0.0.1:5432","frameworks":["CI","Playwright","Jest"],"classification":"environment","summary":"The test process reached the target host, but no service was accepting connections on the requested port.","causes":[{"title":"The dependency never became ready","explanation":"A database, API, or web server started slowly or crashed during boot.","diagnostic":"Read the dependency logs and probe its health endpoint before running tests.","fix":"Gate the suite on a bounded health check and fail with the dependency logs."},{"title":"localhost points at the wrong container","explanation":"Inside a container, 127.0.0.1 refers to that container rather than another service.","diagnostic":"Print the resolved base URL and compare it with the CI service name and network.","fix":"Use the CI service hostname or expose the correct host gateway."},{"title":"The configured port differs from the listening port","explanation":"Environment variables and container mappings can disagree.","diagnostic":"Compare the application listen address, health check, and test base URL.","fix":"Use one validated configuration value and publish the correct container port."}],"prevention":["Use explicit health checks.","Validate base URLs at suite startup.","Attach service logs on failure."],"related":["dns-resolution-failed-in-ci","database-pool-exhausted","playwright-timeout-exceeded"],"references":[{"label":"Node.js common system errors","url":"https://nodejs.org/api/errors.html#common-system-errors"}]}