I am working with docker-compose and I am trying to deploy it on a VPS Centos 8 but keycloak can’t access to the postgres database.
However I can connect to the database with pgAdmin.
I have those following errors :
Caused by: java.net.NoRouteToHostException: No route to host (Host unreachable)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
at java.base/java.net.Socket.connect(Socket.java:609)
at [email protected]//org.postgresql.core.PGStream.<init>(PGStream.java:70)
at [email protected]//org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:91)
at [email protected]//org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
... 62 more
13:34:55,281 FATAL [org.keycloak.services] (ServerService Thread Pool -- 65) java.lang.RuntimeException: Failed to connect to database
and
13:34:56,307 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([("subsyste m" => "microprofile-metrics-smallrye")]): java.lang.NullPointerException
at [email protected]//org.wildfly.extension.microprofile.metrics.MicroProfileMetricsSubsystemAdd$ 2.execute(MicroProfileMetricsSubsystemAdd.java:86)
at [email protected]//org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:999)
at [email protected]//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:743)
at [email protected]//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:467)
at [email protected]//org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1413)
at [email protected]//org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:527)
at [email protected]//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:515)
at [email protected]//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:477)
at [email protected]//org.jboss.as.server.ServerService.boot(ServerService.java:448)
at [email protected]//org.jboss.as.server.ServerService.boot(ServerService.java:401)
at [email protected]//org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:416)
at java.base/java.lang.Thread.run(Thread.java:834)
This is my docker-compose.yml :
version: "3.7"
services:
keycloak:
container_name: app-keycloak
depends_on:
- postgres
environment:
# Admin account
KEYCLOAK_USER: foo
KEYCLOAK_PASSWORD: foo
#KEYCLOAK_IMPORT: /tmp/realm-export.json
# PostgreSQL DB settings
DB_VENDOR: POSTGRES
DB_ADDR: postgres
DB_PORT: 5432
DB_DATABASE: foo
DB_SCHEMA: public
DB_USER: foo
DB_PASSWORD: foo
image: "jboss/keycloak:10.0.2"
ports:
- "9999:8080"
restart: always
networks:
- auth-network
postgres:
container_name: app-postgres
environment:
POSTGRES_DB: foo
POSTGRES_PASSWORD: foo
POSTGRES_USER: foo
image: "postgres:13-alpine"
ports:
- "5432:5432"
restart: always
volumes:
- "./volumes/postgres-data:/var/lib/postgresql/data"
networks:
- auth-network
networks: auth-network:
driver: bridge
Do you have any ideas of how I can resolve this ?
2
Answers
With my my Windows 10 PC, that solution work but I still have thoses errors on my VPS Centos 8. Do you have others ideas ?
firewall-cmd --zone=public --list-all
Working example for me