Independent testing Updated April 2026 387 self-hosting guides 5 VPS providers tested

guide

How to Self-Host Keycloak on a VPS (Complete Guide)

A complete step-by-step guide to self-hosting Keycloak on a VPS in 2026, covering installation, configuration, securing Keycloak, and the specs you need.

Introduction

Keycloak is an open-source identity and access management solution that allows you to manage user authentication and authorization. Self-hosting Keycloak on a Virtual Private Server (VPS) offers you complete control over your authentication process, making it a popular choice among developers and homelab enthusiasts. In this guide, we will walk through the steps to install Keycloak on a VPS, especially focusing on using Docker to simplify deployment.

Choosing the Right VPS Provider

When selecting a VPS for self-hosting Keycloak, consider performance, pricing, and available resources. Hereโ€™s a comparison of some top VPS providers that you can consider for your Keycloak deployment:

ProviderMonthly PriceRAMCPU CoresStorage
Contabo VPS5.99 EUR4 GB2300 GB SSD
Hetzner Cloud4.15 EUR2 GB120 GB SSD
DigitalOcean6 USD1 GB125 GB SSD
Vultr6 USD1 GB125 GB SSD
Linode (Akamai)5 USD2 GB150 GB SSD

You can find a full VPS comparison for deeper insights.

Prerequisites

Before we begin, ensure you have the following:

  1. A VPS with adequate resources (at least 2 GB RAM recommended).
  2. A domain name pointed to your VPS IP address (optional but recommended).
  3. Basic knowledge of Linux command line and SSH.

Installing Keycloak on VPS

Step 1: Access Your VPS

Connect to your VPS via SSH. Replace your-user and your-ip with your username and VPS IP address.

ssh your-user@your-ip

Step 2: Install Docker

Installing Keycloak using Docker simplifies the setup and management process. Hereโ€™s how to install Docker on an Ubuntu server:

sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install -y docker-ce

To verify the installation:

docker --version

Step 3: Start Keycloak Using Docker

To run Keycloak as a Docker container, execute the following commands:

sudo docker pull jboss/keycloak
sudo docker run -d -p 8080:8080 --name keycloak \
-e KEYCLOAK_USER=admin \
-e KEYCLOAK_PASSWORD=password \
jboss/keycloak

In this command, KEYCLOAK_USER and KEYCLOAK_PASSWORD are set to create an admin user. Ensure to change these to secure credentials.

Step 4: Access Keycloak

After the container starts, access Keycloak by navigating to http://your-vps-ip:8080/auth in your web browser. Use the credentials you set to log in.

Step 5: Configuring Keycloak

Upon first login, you can begin configuring your realms, clients, and users. Keycloak offers extensive documentation to help with these configurations.

Best Practices for Self-Hosting Keycloak

  1. Secure Your VPS: Regularly update your system and use a firewall to restrict access.
  2. Enable HTTPS: Use Letโ€™s Encrypt to create a free SSL certificate and configure Keycloak to run over HTTPS.
  3. Backup Data: Regularly backup your Keycloak database and container settings.

FAQs

1. Can I run Keycloak without Docker?

Yes, you can install Keycloak without Docker. You can download the standalone server from the Keycloak website and follow the installation instructions provided for your operating system. However, using Docker offers easier deployment and management, with fewer conflicts in dependencies.

2. How do I scale Keycloak on a VPS?

To scale Keycloak on a VPS, you can deploy multiple instances of Keycloak behind a load balancer. Consider using Docker Compose or Kubernetes for orchestrating multiple containers. Each instance should share the same database to maintain session consistency. Ensure your VPS has ample resources to handle the additional load effectively.

3. What databases can Keycloak use?

Keycloak supports various databases, including PostgreSQL, MySQL, MariaDB, and even H2 for development purposes. For production environments, PostgreSQL or MySQL is recommended due to their robustness and scalability. You can configure the database connection in standalone.xml or via environment variables in Docker.

By following these instructions, you can successfully self-host Keycloak on a VPS and take control of your identity and access management. For more insights on self-hosting applications, consider exploring communities like r/selfhosted or repositories such as awesome-selfhosted for additional resources and guidance.