Repository navigation
Replies: 1 comment
|
Moved to a discussion rather than an issue. From the log, you do show Keycloak trying to connect to 5413, but that is refused. Then you describe that the full url works but only with the default port. The only conclusion is that the database only reachable from keyclaok via the default port and not 5413. This is not really a keycloak issue, I think it has to do more with your docker compose setup. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Before reporting an issue
Area
storage
Describe the bug
I am running Keycloak 26.3.0 docker container in production mode backed by a postgres database docker container. The containers are in the same docker network. When the postgres database is configured with the default port of 5432, keycloak connects just fine. But when i run postgres on a custom port , and also configure Keycloak to connect to the database using the environment variable KC_DB_URL_PORT, set for that custom port, keycloak fails to start.
Version
26.3.0
Regression
Expected behavior
Keycloak is expected to start successfully, having connected successfully to the database at the port defined by the environment variable KC_DB_URL_PORT or using the KC_DB_URL and including the custom port in the url.
Actual behavior
The logs for the keycloak docker container are as below. As can be seen, the server is not connecting via the custom port 5413. I can even confirm that the database is up and running and is accessible using a database client and can connect to it successfully using the custom port.
How to Reproduce?
The issue can be reproduced by running the following docker compose file
services: keycloak: container_name: keycloak-cdc image: quay.io/keycloak/keycloak:26.3.0 environment: KC_BOOTSTRAP_ADMIN_USERNAME: $KC_BOOTSTRAP_ADMIN_USERNAME KC_BOOTSTRAP_ADMIN_PASSWORD: $KC_BOOTSTRAP_ADMIN_PASSWORD KC_DB: postgres KC_DB_URL_HOST: postgres_cdc_keycloak KC_DB_URL_DATABASE: keycloak KC_DB_URL_PORT: 5413 # KC_DB_URL: "jdbc:postgresql://postgres_cdc_keycloak:5413/keycloak" KC_DB_PASSWORD: $KC_DB_PASSWORD KC_DB_USERNAME: $KC_DB_USERNAME KC_DB_SCHEMA: public KC_HTTPS_PORT: $KC_HTTPS_PORT KC_HTTP_PORT: $KC_HTTP_PORT KC_HTTPS_CERTIFICATE_FILE: $KC_HTTPS_CERTIFICATE_FILE KC_HTTPS_CERTIFICATE_KEY_FILE: $KC_HTTPS_CERTIFICATE_KEY_FILE KC_HOSTNAME_ADMIN: $KC_HOSTNAME_ADMIN KC_HOSTNAME: $KC_HOSTNAME KC_PROXY_HEADERS: xforwarded KC_HEALTH_ENABLED: true KC_METRICS_ENABLED: true KC_HTTPS_REQUIRED: none # KC_HOSTNAME_BACKCHANNEL_DYNAMIC: true # KC_CACHE_CONFIG_FILE: cache-ispn.xml # KC_LOG_LEVEL: debug networks: - cdc-net command: - "start" depends_on: - postgres_cdc_keycloak # - keycloak_jgroups_postgres healthcheck: test: [ "CMD","curl", "--head","-fsS","https://localhost:9445/health" ] interval: 10s timeout: 5s retries: 5 volumes: - ./app/certs:/opt/keycloak/conf/certs # - ./app/infinispan/cache-ispn.xml:/opt/keycloak/conf/cache-ispn.xml - ./app/providers:/opt/keycloak/providers postgres_cdc_keycloak: image: postgres:17.5 command: postgres -c 'max_connections=200' volumes: - pgdata_cdc_keycloak:/var/lib/postgresql/data environment: POSTGRES_DB: $POSTGRES_DB POSTGRES_USER: $POSTGRES_USER POSTGRES_PASSWORD: $POSTGRES_PASSWORD ports: - "5413:5432" networks: - cdc-net keycloak-nginx: build: context: ./app/nginx dockerfile: nginx.dockerfile ports: - "9090:80" - "9445:443" depends_on: - keycloak networks: - cdc-net networks: cdc-net: driver: bridge volumes: pgdata_cdc_keycloak:Alternatively,I even tried to use the KC_DB_URL environment variable and specifying the custom port , but the Keycloak server only started successfully when using the default db port for postgres but failed for any custom ports.
Anything else?
No response
All reactions