My Keycloak is runnining in docker cointainer from starting onwords and the next js application with keycloak configuration is running locally fine. when i made my next js build and made cointainerized then the 3000 port of my next js is running when tray to sign in throw keycloak it shows in Try signing in with a different account. and in docker console shows this error . [next-auth][error][SIGNIN_OAUTH_ERROR]
2024-01-22 15:55:56 Errors | NextAuth.js connect ECONNREFUSED 127.0.0.1:8080 {
2024-01-22 15:55:56 error: {
2024-01-22 15:55:56 message: âconnect ECONNREFUSED 127.0.0.1:8080â,
2024-01-22 15:55:56 stack: âError: connect ECONNREFUSED 127.0.0.1:8080\nâ +
2024-01-22 15:55:56 â at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1571:16)',
2024-01-22 15:55:56 name: âErrorâ
2024-01-22 15:55:56 },
2024-01-22 15:55:56 providerId: âkeycloakâ,
2024-01-22 15:55:56 message: âconnect ECONNREFUSED 127.0.0.1:8080â
2024-01-22 15:55:56 }
2024-01-22 15:55:12
2024-01-22 15:55:12 > assess-it@0.1.0 start
2024-01-22 15:55:12 > next start
Share docker-compose.yml
or your CLI commands.
Hii ,
This is my docker-compose.yml file when i run this by docker-compose up command it will create new keycloak for me,but my keycloak is already running in another container with my backend and front end configuration. version: â3â
services:
nextjs-app:
image: assessit
ports:
- â3000:3000â
depends_on: - keycloak
keycloak:
image: jboss/keycloak
environment:
- KEYCLOAK_USER=akash
- KEYCLOAK_PASSWORD=Akash@123
ports: - â8080:8080â
You config gives me the impression you are a beginner, not sure if an enterprise tool like keycloak is the right one. Format config before and after with 3 backticks.
When using multiple containers, you usually attach them to a Docker network for internal communication, only the proxy opens the ports externally (see simple Traefik example). Then you can access other service/container by service name through Docker DNS.
You can not use localhost/127.0.0.1
inside a container to connect to another, as that is localhost
inside the container, not the one of the node/host.
Why did you tag this post with âswarmâ?
Hello @akashtpd,
It looks like you are having a network issue. I explained how you can setup this environment in this post:
I used next-auth but still if you take a look at the .env.local and route.ts configuration Iâm pretty sure you can solve it.
Take care and let me know if you have any questions!