Connection Refused when accessing a protected resource inside docker

Hi,
I am trying to secure a spring boot application with keycloak and oauth2.
I was able to secure the application when it wasn’t on docker and it works fine from intellij, i was able to access a protected resource.
But when i run the application in a docker container, i get connection refused error
However i was redirected to keycloak login page, authenticated successfully but i wasn’t able to reach the protected resource.
I am also running keycloak inside a docker container on port 8086.
I also configured nginx reverse proxy for keycloak.

Thanks in advance for your help

When you try to connect localhost from a docker container. ‘localhost’ refers to the docker container itself. I believe this question is relevant to your problem.

Thanks

2 Likes

Thank you, that worked for me

1 Like