Does a Managed Keycloak Cluster Have a Static IP Address?

Mariam SolimanMariam Soliman8 min read

Do not build on a fixed IP address for a managed Keycloak cluster on Skycloak: as our custom domains architecture guide shows, every request reaches it through Cloudflare’s network, on IP addresses that Cloudflare shares across all the hostnames it proxies and that can change. Allowlist your cluster’s hostname, or Cloudflare’s published IP ranges, never a single IP address, and always call Keycloak by its hostname, because both its TLS certificate and the issuer in its tokens depend on that name.

We get this question from IT and platform teams who run on-premises machines (office desktops, kiosks, servers on a factory network) that sign in through a managed Keycloak cluster. Usually something has already gone wrong: the local DNS server had a bad hour, nobody could sign in, and the natural fix seems to be a hard-coded IP address. This post explains why that fix does not work with Keycloak, what to put in your firewall instead, and how to keep sign-in working when your own DNS fails.

Why doesn’t a managed Keycloak cluster have a fixed IP?

Every request to a Skycloak cluster first reaches Cloudflare’s edge, which handles TLS and DDoS protection and then forwards the traffic to the Kubernetes cluster that runs your Keycloak. Our custom domains architecture guide shows that path step by step, and it is the same whether you use the hostname we give your cluster or your own custom domain, which is a CNAME (a DNS alias) that points into the same network.

Cloudflare documents that when a hostname is proxied, “visitors who look up your domain receive a Cloudflare IP address instead of your origin server’s real IP address”, and that its address ranges “are shared by all proxied hostnames” (Cloudflare IP addresses). The address your DNS lookup returns today is therefore not reserved for your cluster. Many other sites answer on it too, and Cloudflare decides which site you meant from the hostname inside the request. That is why the hostname is the stable thing to build on.

Why does calling Keycloak by IP address break sign-in?

Even if you looked up the current address and hard-coded it, three separate things would break, and only the first one is about the address changing later.

The address is shared and can change

Because the address is shared, a request sent to it with no hostname typically gives the edge nothing to route on, so in practice it will not reach your cluster. A request that does carry the hostname but goes to a pinned address keeps working only until the answer for that name moves, and nothing tells your machines when that happens. You would find out the way you found out about the DNS outage, from people who cannot sign in.

The TLS certificate is issued for the hostname

A TLS certificate proves that the server you reached owns a particular name. HTTPS clients must check that the certificate matches the host in the URL, and when that host is a literal IP address, the certificate has to list that exact address (RFC 9110, section 4.3.4). A call to https:// plus an IP address therefore fails with a name mismatch unless the certificate also lists that address. Our post on fixing Keycloak SSL certificate errors walks through that family of errors, and turning off certificate checks to get past it would remove the protection TLS gives you.

The token issuer is built from the hostname

Keycloak builds the URLs it hands out (the login page, the token endpoint, the OpenID Connect discovery document) from its configured hostname. The Keycloak hostname guide says “The base URL for each group has an important impact on how tokens are issued and validated”, and the same guide explains that setting the hostname option explicitly matters for the tokens Keycloak issues. OpenID Connect requires an application to check that the issuer in an ID token exactly matches the issuer it expects (OpenID Connect Core, ID Token Validation), and the issuer a Keycloak realm publishes is a URL, as the discovery document checked in the test below shows. An application configured with an IP address would then expect an issuer that does not match the tokens it receives, and it would likely reject them.

Running Keycloak behind a proxy follows the same rule. Our guide to running Keycloak behind a reverse proxy covers the self-hosted side, where the Keycloak reverse proxy guide warns that a misconfigured proxy setup “will leave Keycloak exposed to security vulnerabilities”. The public name is what Keycloak trusts, and the address underneath it is an implementation detail.

Calling a managed Keycloak cluster by a shared edge IP fails on the certificate name, while calling it by hostname reaches your Keycloak with a matching certificate and issuer

An on-premises machine that calls a shared edge IP directly (1) reaches an address many hostnames use (2), so the certificate name does not match and sign-in fails (3). The same machine calling the cluster’s hostname (4) lets Cloudflare read the name and forward the request (5) to your Keycloak, where the certificate and the token issuer both match (6).

How do you allowlist a managed Keycloak cluster on an on-premises firewall?

If your machines sit behind a firewall that only lets outbound HTTPS through to approved destinations, you have two workable options. Both start from your cluster’s hostname, the hostname shown in your dashboard.

  1. Allow the hostname. Many firewalls and web proxies accept a fully qualified domain name (FQDN) as a destination object and resolve it themselves. Add your cluster’s hostname on port 443. Make sure the firewall uses the same DNS resolvers as your machines, so that both see the same answer when it changes.
  2. Allow Cloudflare’s published ranges. If your firewall only takes IP addresses, allow the IPv4 and IPv6 ranges on Cloudflare’s IP ranges page, which describes itself as “the definitive source of Cloudflare’s current IP ranges” and also offers them as plain IPv4 and IPv6 text lists. Cloudflare says its ranges “do not change frequently” and that new ones are added to that list “before being put into production” (Cloudflare IP addresses), so a scheduled job that fetches the text lists keeps your rule current.

Be aware of what the second option means: it opens port 443 to every site behind Cloudflare, not only to your cluster. If that is too broad for your security policy, the hostname rule is the tighter one.

You may also be looking for the opposite direction, which is limiting which addresses can reach your cluster, for example keeping the Admin Console open only to your office. That is IP access control, which our security hardening guide shows how to set on the IP Access Control card of your cluster’s Security page, and it sits next to the country rules in our post on geo-blocking your Keycloak cluster.

The cluster, without the on-call

Skycloak runs real upstream Keycloak in the region you choose, and takes the upgrades, backups, certificate rotation and patching off your team. No fork, so you can export and self-host whenever you want.

How do you keep sign-in working when local DNS fails?

The real problem behind most static IP requests is a single point of failure in your own DNS, so fix that instead of pinning an address. A hosts file entry looks like a quick fix, but it turns a shared, changing address into a permanent one on every machine that has it, and the day the address moves, those machines fail in a way that is hard to trace because DNS looks healthy.

These changes give you the same protection without pinning anything:

  • Give every machine at least two resolvers. Configure a second DNS server through DHCP or your device management, ideally one that does not depend on the same hardware, network link or upstream as the first. When the primary stops answering, clients move to the secondary.
  • Run a caching resolver close to the machines. A local caching resolver keeps recent answers, including your cluster’s hostname, for as long as their time to live allows. RFC 8767 defines a method, “serve-stale”, for recursive resolvers “to use stale DNS data” when the authoritative servers cannot be reached. Turn it on if your resolver supports it.
  • Watch the resolver, not only the application. An alert when your internal DNS stops answering tells you about the problem before users report that they cannot sign in.

If machines still cannot reach the cluster after DNS answers correctly, the cause is somewhere else on the path, and our Keycloak connection refused troubleshooting guide goes through the usual suspects.

How do you test it on one machine?

Before you roll a rule out to every site, check it on one test machine behind the same firewall. Replace the placeholders with your cluster’s hostname and a realm name.

# 1. The hostname resolves through your resolvers
nslookup YOUR-CLUSTER-HOSTNAME

# 2. HTTPS works through the firewall and the certificate is valid
curl -sS https://YOUR-CLUSTER-HOSTNAME/realms/YOUR-REALM/.well-known/openid-configuration

# 3. The issuer in the discovery document is the hostname, not an IP
curl -sS https://YOUR-CLUSTER-HOSTNAME/realms/YOUR-REALM/.well-known/openid-configuration | grep -o '"issuer":"[^"]*"'

Then sign in to one of your applications from that machine. To test the DNS failure case, stop or block the primary resolver for that machine only and sign in again. It should keep working through the secondary resolver or the cached answer. If it does, roll the same firewall rule and resolver settings out to the rest of your machines.

FAQ

Can I get a dedicated static IP for my Skycloak cluster?

Clusters are served through Cloudflare’s shared network, so the address a DNS lookup returns is not reserved for your cluster. Use the hostname, or Cloudflare’s published ranges if your firewall only accepts addresses.

Can I put the Keycloak IP address in a hosts file?

You can, but it will break without warning when the shared address changes, and it hides the failure because DNS keeps working for everything else. A second resolver or a caching resolver protects you against DNS outages without that risk.

Why do I get a certificate error when I call Keycloak by IP address?

The TLS certificate is issued for the cluster’s hostname, and an IP address is usually not one of the names in it, so the client typically rejects the connection. Call the hostname instead.

Does using a custom domain change any of this?

No. A custom domain is a DNS alias that points into the same Cloudflare network, so it has no fixed IP either. Allowlist the custom domain the same way, and keep your applications pointed at a hostname rather than an address.

Next steps

Allowlist your cluster’s hostname, or Cloudflare’s published ranges, on one test machine’s firewall, confirm that sign-in works with the commands above, and then roll the rule out to your other machines. If your network rules cannot work that way, contact us with Report a problem in the dashboard (see reporting a problem) and we will look at your setup with you. To have us run Keycloak, its networking and its certificates for you, see managed Keycloak hosting.

The cluster, without the on-call

Skycloak runs real upstream Keycloak in the region you choose, and takes the upgrades, backups, certificate rotation and patching off your team. No fork, so you can export and self-host whenever you want.

Mariam Soliman
Written by
Customer Success, Skycloak

Mariam works in customer success at Skycloak, helping teams get set up on managed identity and stay successful once they are live. She writes about the questions customers bring to us most often.

© 2026 Skycloak. All Rights Reserved. Design by Yasser SolimanKeycloak™ is a trademark of the Linux Foundation. Skycloak is not affiliated with the Keycloak project.