ECONNREFUSED Docker Issue

I’m trying to setup a developer environment where all components are containerized with Docker. If I run my API locally without a container, I can get things to work. However once I run my API in a Docker container any request I send to an endpoint that is protected by KeyCloak it results in ECONNREFUSED.

Environment

If I attempt to manually authenticate through the API (Direct Access Grants Enabled) it also only works if the API isn’t in a Docker contain.

I suspect this is a configuration issue. That KeyCloak doesn’t like the source of the requests.

You need to be more familiar with container and you need to known that localhost in the container is not the same as OS localhost. Container runs in different network namespace (usually). So my guess is that your are not using right localhost in your app.

1 Like