Skip to content

Keycloak hostname configuration helper

Work out the hostname, admin hostname, backchannel and proxy options for your Keycloak setup, using the hostname options of Keycloak 25 and later.

Runs in your browser. Nothing you paste is sent to us.

Your setup

What browsers and apps use, with any path. A made-up address is filled in.

Set only the kind your proxy writes, and make sure it overwrites what clients send.

Keycloak then reads proxy headers only from these addresses or ranges.

Options

Configuration
KC_HOSTNAME=https://auth.example.com
KC_HTTP_ENABLED=true
KC_PROXY_HEADERS=xforwarded
Issuer of realm acme
https://auth.example.com/realms/acmeshould match the iss of its tokens
Discovery
https://auth.example.com/realms/acme/.well-known/openid-configurationits URLs should all start with the public address
Admin console
https://auth.example.com/admin/master/console/
What each option does
  • hostname: the address Keycloak puts in tokens, links and redirects. A full URL sets the scheme, port and path too.
  • hostname-admin: where the admin console is served, when it differs.
  • hostname-backchannel-dynamic: lets back-end calls (token, introspection) use the address the request came in on. Needs hostname as a full URL.
  • hostname-strict: on by default, which makes hostname required. Turned off, Keycloak builds its URLs from each request’s Host header: only for development.
  • proxy-headers: which forwarded headers to read. Only set it when a proxy you control overwrites them.

How to use it

  1. Enter the public address people and apps use.
  2. Add a separate admin console address if you have one.
  3. Say where HTTPS ends and which forwarded headers your proxy sets.
  4. Copy the options in the format you deploy with, then open the discovery URL to check.

What to know

Keycloak puts its hostname in tokens, links and redirects, so it must be the address people actually use. Since version 25, hostname takes a full URL that sets the scheme, port and path in one go.

hostname-admin serves the admin console on its own address. hostname-backchannel-dynamic lets back-end calls use the address they came in on, for apps that reach Keycloak inside a private network.

Behind a proxy that ends HTTPS, turn on http-enabled and set proxy-headers to the kind of headers your proxy writes. Keycloak trusts those headers, so the proxy must overwrite whatever clients send.

What the hostname setting decides

Keycloak writes its own address into almost everything it sends out. The iss claim in every token, the URLs in the discovery document, the links in password reset emails, the redirects during sign-in and the address of the admin console all come from one place: the hostname configuration.

If that address is wrong, the symptoms show up far from the cause. Apps reject tokens because the issuer does not match. Browsers loop between two addresses. Email links point at an internal host name nobody can reach. The admin console loads a blank page because its scripts come from the wrong origin.

Getting the hostname right is usually the first real task of a production deploy, and the first thing to recheck after a move to a new network, a new proxy or a new cluster.

How Keycloak 26 handles the hostname

Keycloak 25 introduced a new set of hostname options, and Keycloak 26 removed the old ones. If you have notes or scripts that use hostname-url, hostname-admin-url, hostname-port, hostname-path or proxy=edge, they no longer apply.

The current options are few, and each has one job.

hostname

The public address of the server. It can be a bare host name such as auth.example.com, or a full URL such as https://auth.example.com. A full URL also fixes the scheme, the port and the path, so it is the clearer choice for production.

With a full URL in hostname, Keycloak builds front-end URLs from it no matter which address a request came in on.

hostname-admin

An address of its own for the admin console, as a full URL. Use it when the console should live on a separate host that only your team can reach, for example a host name that resolves only inside a VPN.

hostname-backchannel-dynamic

When set to true, back-end requests such as token, introspection and UserInfo calls may use the address they arrived on, instead of the public one. This helps when apps inside a private network call Keycloak at an internal address. It needs hostname to be a full URL.

hostname-strict

On by default. With it on, Keycloak refuses to start in production mode until hostname is set. Turning it off makes Keycloak build URLs from the Host header of each request, which is only safe on your own machine.

proxy-headers and http-enabled

These are not hostname options, but they decide how Keycloak reads requests that pass through a proxy. proxy-headers takes xforwarded or forwarded and tells Keycloak which forwarded headers to trust. http-enabled=true lets Keycloak listen on plain HTTP, which you need when TLS ends at the proxy.

A typical production setup

Most production deployments put a reverse proxy or load balancer in front of Keycloak. The proxy holds the certificate and sends plain HTTP to Keycloak on port 8080. The options for that setup are short.

Environment variables, TLS at the proxy
KC_HOSTNAME=https://auth.example.com
KC_HTTP_ENABLED=true
KC_PROXY_HEADERS=xforwarded

The same options as command-line flags look like this. Keycloak accepts either form, and the command line wins when both are set.

Command line
bin/kc.sh start \
  --hostname=https://auth.example.com \
  --http-enabled=true \
  --proxy-headers=xforwarded

The address auth.example.com is a placeholder. Use the address your users type or click.

What this tool does

The hostname helper asks a few questions about your setup and writes the matching options. It works out the value of hostname from the public address you enter, adds hostname-admin when the console has its own address, and sets http-enabled and proxy-headers when TLS ends at a proxy.

It can also add proxy-trusted-addresses, so Keycloak reads forwarded headers only from your proxy, and http-relative-path when Keycloak itself serves under a path such as /auth. The result comes out as a command line, environment variables, a Compose block, a Kubernetes env list or keycloak.conf lines.

Under the options it shows the issuer and discovery URL for a sample realm, so you know what to open in a browser to check the result.

What it does not do

  • It does not contact your server. Everything runs in your browser, so it cannot see what your proxy actually sends.
  • It does not write the certificate options for you. When Keycloak serves HTTPS itself, you still add https-certificate-file and https-certificate-key-file or a key store.
  • It does not configure the proxy. The reverse proxy config tool writes nginx, Caddy and Traefik configs that match these options.

How to use it

  1. Enter the public address as a full URL, with the path if Keycloak sits under one.
  2. Tick the admin console box if the console has an address of its own, and enter that address.
  3. Pick where HTTPS ends: at a proxy, passed through the proxy, or at Keycloak itself.
  4. If a proxy ends TLS, pick the kind of headers it writes and, if you can, list the proxy addresses to trust.
  5. Tick the internal network box if your apps call Keycloak at a private address.
  6. Copy the options in the format you deploy with, restart Keycloak, and open the discovery URL to check every URL in it.

Where it helps

The same few options come up in very different situations. These are the most common.

A first production deploy

Development mode with start-dev does not need a hostname, so many teams first meet these options when they switch to start. Keycloak then refuses to start without hostname, and the helper gives you a complete, consistent set in one step.

Behind a load balancer

A cloud load balancer usually ends TLS and forwards plain HTTP. Keycloak needs http-enabled, proxy-headers and a full URL in hostname, or it builds http:// URLs and the browser gets redirected in a loop. Check which header style your load balancer writes before you pick one.

Moving from a VM to Kubernetes

On a VM, Keycloak may have been reachable on its own address. In a cluster, it sits behind an ingress or a gateway, and apps inside the cluster may call it through a service name. The public hostname stays the same; hostname-backchannel-dynamic covers the internal calls.

Upgrading from an older version

Upgrades from Keycloak 24 or earlier often fail at start because the old hostname and proxy options are gone. Translate them once: hostname-url becomes a full URL in hostname, hostname-admin-url becomes hostname-admin, and proxy=edge becomes http-enabled=true plus proxy-headers.

Common errors and how to fix them

Keycloak will not start: hostname is not configured

Production mode needs hostname while hostname-strict is on. Set hostname to the public URL. Do not turn off hostname-strict to make the error go away on a real server.

A redirect loop or "HTTPS required"

Keycloak thinks the request came over plain HTTP. Either the proxy does not send X-Forwarded-Proto: https, or proxy-headers is not set, so Keycloak ignores what the proxy sends. Set proxy-headers to match the proxy and check that the proxy writes the header.

Tokens rejected because of the issuer

Apps compare the iss claim with the issuer they were configured with. If the two differ by scheme, port or path, validation fails. Open the discovery document and copy the issuer value into the app, or fix hostname so it matches what the app expects.

Email links point at an internal address

Links in emails are built from the front-end address. If hostname is not set to the public URL, or the proxy forwards the wrong host, links carry an internal name. Set hostname as a full URL and the links follow it.

The admin console loads a blank page

This often means the console is served on one address but loads its resources from another that the browser cannot reach. Check hostname-admin and make sure the proxy passes /admin/ and /resources/ on that host.

Security notes

  • Only set proxy-headers when a proxy you control sits in front and overwrites the forwarded headers. Otherwise any client can claim to be any host or scheme.
  • Use proxy-trusted-addresses where you can, so forwarded headers from anywhere else are ignored.
  • Keep hostname-strict on in production. Building URLs from the Host header lets an attacker influence links in emails and redirects.
  • Put the admin console on its own host with hostname-admin, and limit who can reach that host at the network level.

Best practices

  • Always give hostname as a full URL with https://. It removes guesswork about scheme and port.
  • Pick one public address per server and use it everywhere: in apps, in identity provider settings and in documentation.
  • After any change, open /realms/<realm>/.well-known/openid-configuration and check that every URL starts with the public address.
  • Keep the options in one place, either environment variables or keycloak.conf, so nobody overrides them by accident.
  • Write the old-to-new option mapping into your upgrade notes before you upgrade from an older major version.

Checking the result

A quick test after a restart catches most mistakes. Fetch the discovery document from outside your network and look at three fields.

Check the issuer
curl -s https://auth.example.com/realms/acme/.well-known/openid-configuration \
  | jq -r .issuer,.authorization_endpoint,.token_endpoint

All three should start with your public address. If any of them shows http://, an internal host or a wrong port, the hostname or proxy settings still need work.

Questions

Frequently asked questions

What replaced hostname-url and proxy=edge in Keycloak?

Keycloak 25 introduced hostname options that take a full URL in `hostname` and `hostname-admin`, and `proxy-headers` in place of the proxy modes. The old options are gone in Keycloak 26. `proxy=edge` maps to `http-enabled=true` plus `proxy-headers`.

Should KC_HOSTNAME include https://?

It can be a bare host name, but a full URL is clearer. A full URL fixes the scheme, port and path that Keycloak writes into tokens and links, so it does not depend on what the proxy sends.

Why does the issuer in my tokens show the wrong address?

Keycloak builds the issuer from its hostname setting, or from the request when hostname is not set. Set `hostname` to the public URL, and set `proxy-headers` if a proxy sits in front.

Should I turn off hostname-strict?

Only in development. With it off, Keycloak trusts the Host header of each request, which a client can change. In production, set `hostname` instead.

What does hostname-backchannel-dynamic do?

It lets back-end calls such as the token and introspection endpoints use the address the request came in on. Apps inside a private network can then call Keycloak at an internal address. It needs `hostname` set as a full URL.

How do I run the admin console on a separate host name?

Set `hostname-admin` to the full URL of that host and route it to Keycloak in your proxy. Keep the public host from serving `/admin/` so the console is only reachable where you intend.

Do I need http-enabled behind a reverse proxy?

Yes, when the proxy ends TLS and sends plain HTTP to Keycloak. Production mode serves only HTTPS unless `http-enabled=true` is set. With TLS passthrough, Keycloak needs its own certificate instead.

Which should I choose, xforwarded or forwarded?

Choose the one your proxy writes. Most proxies and load balancers write the `X-Forwarded-*` headers, which is `xforwarded`. The standard `Forwarded` header is `forwarded`.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.