Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

Keycloak in Docker cannot use its PostgreSQL URL at start-up

Your error

Driver does not support the provided URL: jdbc:postgresql://postgres:5432/keycloak1 more line it can show

Fix it fast

Most common cause, 1 of 2

KC_DB is not set, so Keycloak keeps its dev-file driver

Set the vendor next to the URL and pass the credentials through their own options.

Fix
services:
  keycloak:
    image: quay.io/keycloak/keycloak:26.8.2
    command: start-dev   # or start, with your hostname and TLS settings
    environment:
      KC_DB: postgres
      KC_DB_URL: jdbc:postgresql://postgres:5432/keycloak
      KC_DB_USERNAME: keycloak
      KC_DB_PASSWORD: change-me

# optimized image (Containerfile)
# ENV KC_DB=postgres
# RUN /opt/keycloak/bin/kc.sh build
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Keycloak fails with Driver does not support the provided URL when the JDBC driver it chose cannot read KC_DB_URL. Either KC_DB is not set, so Keycloak still uses its default dev-file database and driver, or the URL is a postgresql:// connection string instead of a jdbc:postgresql:// URL. Set KC_DB=postgres and a JDBC URL. Applies to Keycloak 26.

  • Applies to Keycloak 26.8.2 (quay.io/keycloak/keycloak), PostgreSQL JDBC driver shipped with Keycloak, Docker Engine 29
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

List the database variables the Keycloak container really received. No KC_DB line, or old names such as DB_VENDOR instead, is cause 1. A KC_DB_URL that does not start with jdbc:postgresql: is cause 2.

Run this first
docker exec keycloak env | grep -E '^(KC_DB|DB_)'

Then find the line you see in this list and open its fix:

  1. 1KC_DB is not set, so Keycloak keeps its dev-file driverenv shows KC_DB_URL with a jdbc:postgresql URL but no KC_DB line, or only variables like DB_VENDOR and DB_ADDR
  2. 2KC_DB_URL holds a postgresql:// connection string instead of a JDBC URLThe URL in the error starts with postgresql:// or postgres://, often with the user and password written inside it

What does the error look like?

  • Driver does not support the provided URL: jdbc:postgresql://postgres:5432/keycloak
  • Driver does not support the provided URL: postgresql://keycloak:secret@postgres:5432/keycloak

Cause 1 of 2

KC_DB is not set, so Keycloak keeps its dev-file driver

You seeenv shows KC_DB_URL with a jdbc:postgresql URL but no KC_DB line, or only variables like DB_VENDOR and DB_ADDR

Check

The db option, read from KC_DB, selects the database vendor, and its default is dev-file. Keycloak runs on Quarkus, which derives the JDBC driver class from that vendor, so without KC_DB=postgres the pool loads the dev-file driver and hands it your PostgreSQL URL. A JDBC driver returns null for a URL it cannot handle, and the Agroal pool turns that null into Driver does not support the provided URL. Variables such as DB_VENDOR from compose files written for the old image are not Keycloak options, so they change nothing.

Check
docker inspect keycloak --format '{{range .Config.Env}}{{println .}}{{end}}' | grep -E '^(KC_DB|DB_)'

Fix

Set the vendor next to the URL and pass the credentials through their own options. For an optimized image, set KC_DB before the kc.sh build step in the Containerfile, as Keycloak's container guide does, then start with --optimized.

Fix
services:
  keycloak:
    image: quay.io/keycloak/keycloak:26.8.2
    command: start-dev   # or start, with your hostname and TLS settings
    environment:
      KC_DB: postgres
      KC_DB_URL: jdbc:postgresql://postgres:5432/keycloak
      KC_DB_USERNAME: keycloak
      KC_DB_PASSWORD: change-me

# optimized image (Containerfile)
# ENV KC_DB=postgres
# RUN /opt/keycloak/bin/kc.sh build

Verify

Recreate the container. The log has no driver error, and Keycloak finishes starting.

Verify
docker compose up -d --force-recreate keycloak
docker compose logs keycloak | grep -c "Driver does not support"   # 0

Confirmed by keycloak.org

Did this fix it?

Cause 2 of 2

KC_DB_URL holds a postgresql:// connection string instead of a JDBC URL

You seeThe URL in the error starts with postgresql:// or postgres://, often with the user and password written inside it

Check

Keycloak documents db-url as the full JDBC URL, and every URL form in the PostgreSQL JDBC driver's documentation begins with jdbc:postgresql:. A URI-style connection string such as postgresql://user:pass@host:5432/db lacks that prefix, so even the right PostgreSQL driver declines it and the pool reports the same message, with your string after the colon.

Check
docker exec keycloak sh -c 'echo "$KC_DB_URL"'

Fix

Rewrite the value as a JDBC URL and move the user and password into KC_DB_USERNAME and KC_DB_PASSWORD. Alternatively, drop KC_DB_URL and give only the parts: KC_DB_URL_HOST and KC_DB_URL_DATABASE fill in the default URL for the chosen vendor, and Keycloak ignores them whenever KC_DB_URL is set.

Fix
# full JDBC URL
KC_DB=postgres
KC_DB_URL=jdbc:postgresql://db.example.com:5432/keycloak
KC_DB_USERNAME=keycloak
KC_DB_PASSWORD=change-me

# or only the parts, with KC_DB_URL removed
KC_DB=postgres
KC_DB_URL_HOST=db.example.com
KC_DB_URL_DATABASE=keycloak

Verify

The value printed inside the container now starts with jdbc:postgresql://, and the server starts without the driver error.

Verify
docker exec keycloak sh -c 'echo "$KC_DB_URL"'

Confirmed by jdbc.postgresql.org

Did this fix it?

How do I stop it coming back?

  • Always set KC_DB explicitly; Keycloak's reference marks the dev-file default as deprecated in production mode.
  • Keep KC_DB, the URL and the credentials in one env file per environment, and convert provider connection strings to JDBC form once, in that file.
  • Pin the Keycloak image to a version such as 26.8.2 instead of latest, and rebuild optimized images whenever KC_DB changes.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: TaxiDex, Dispatch Pro.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.