bolt Valebyte VPS from $4/mo — NVMe, 60s deploy.

Get a VPS arrow_forward
eco Beginner Tutorial/How-to

Install Home Assistant on VPS: A Complete

calendar_month Jul 06, 2026 schedule 22 min read visibility 27 views
info

Need a server for this guide? We offer dedicated servers and VPS in 50+ countries with instant setup.

Need a server for this guide?

Deploy a VPS or dedicated server in minutes.

Installing Home Assistant on VPS: A Complete Guide with Docker and SSL

TL;DR

In this guide, we will step-by-step set up Home Assistant on a Virtual Private Server (VPS) using Docker for isolation and ease of management, and ensure secure access via HTTPS with an automatic SSL certificate from Let's Encrypt. You will learn how to prepare the server, deploy Home Assistant, configure access via a domain name, and secure it, gaining full control over your smart home system without relying on third-party cloud services.

  • Full Control: Deploying Home Assistant on your own VPS for maximum privacy and flexibility.
  • Using Docker: Ensuring easy installation, isolation, and updates for Home Assistant and its components.
  • Secure Access: Configuring HTTPS with an automatic SSL certificate via Caddy for secure remote connection.
  • Scalability: Choosing a VPS configuration sufficient for current needs and future smart home system expansion.
  • Maintenance and Backups: Including backup and update strategies for long-term stability.

What We Configure and Why

Home Assistant is a powerful open-source platform for smart home automation that prioritizes privacy and local control. It allows you to combine devices from various manufacturers into a single system, create complex automations, monitor sensor states, and manage all aspects of your home from a unified interface.

In this guide, we will deploy Home Assistant on a Virtual Private Server (VPS). This solution offers several key advantages:

  • Full Control and Privacy: Your data remains on your server. You are not dependent on cloud services and their privacy policies.
  • Flexibility and Scalability: A VPS provides significantly more resources than single-board computers like Raspberry Pi, allowing you to handle more integrations, automations, and store a larger volume of data without performance degradation.
  • 24/7 Reliability: VPS are typically hosted in professional data centers with high availability and stable internet connectivity, ensuring uninterrupted operation of your smart home system.
  • Remote Access: We will configure secure access to Home Assistant from anywhere in the world via a domain name and HTTPS, protected by an SSL certificate.

As alternatives to Home Assistant on a VPS, you can consider:

  • Home Assistant Green/Yellow or Raspberry Pi: A local solution, simple to deploy, but limited in resources and requiring constant power and internet connection in your home.
  • Cloud Smart Home Platforms (Google Home, Amazon Alexa, Apple HomeKit): Convenient, but often require transferring your data to their servers and limit control over devices.
  • Managed Solutions (e.g., Home Assistant Cloud): Offer convenient remote access and integration with voice assistants for a subscription fee, but still depend on a third-party service.

Choosing a self-hosted solution on a VPS allows combining the advantages of local control with the reliability and performance of cloud infrastructure, making it ideal for advanced users and those who value privacy.

What VPS Configuration is Needed for This Task

Choosing the right VPS configuration is critical for stable and fast Home Assistant operation, especially as your smart home system grows.

Minimum Requirements (for small installations, up to 20-30 devices/integrations)

  • CPU: 2 cores (x86-64 architecture)
  • RAM: 4 GB (Home Assistant can be memory-intensive, especially with a database and many add-ons)
  • Disk: 80 GB SSD (a fast disk is important for the Home Assistant database and quick file access; 80 GB provides room for logs, backups, and database growth)
  • Network: 100 Mbps (sufficient for remote access and updates)
  • Operating System: Ubuntu Server 24.04 LTS (recommended)

Recommended VPS Plan (for medium to large installations, 50+ devices, cameras, voice assistants)

  • CPU: 4 cores
  • RAM: 8 GB
  • Disk: 160 GB SSD (with room for long-term data, history, and potential Docker images of other services)
  • Network: 1 Gbps (for fast downloads, video streaming from cameras)
  • Operating System: Ubuntu Server 24.04 LTS

For renting a VPS with these characteristics, you can consider a VPS with the specified characteristics, suitable for reliable Home Assistant hosting.

When a Dedicated Server is Needed, Not a VPS

A dedicated server might be needed in rare cases if:

  • You are planning a very large Home Assistant installation (hundreds of devices, dozens of IP cameras with video processing).
  • You need absolutely all server resources without virtualization.
  • You want to host many other resource-intensive applications on the server besides Home Assistant.
  • Specific hardware is required that is not available on a VPS (e.g., GPU for AI tasks).

In most cases, a well-configured VPS is sufficient for Home Assistant. If your project requires maximum performance and full control over the hardware, you can consider a suitable dedicated server.

Location: What it Affects

The choice of VPS server location can affect several aspects:

  • Latency: If you plan to use Home Assistant to control devices requiring minimal latency (e.g., for instant sensor response), it's better to choose a server geographically close to you or your home. However, for most automations and remote access, a latency of 50-150 ms will not be critical.
  • Legislation: Depending on your preferences for privacy and data storage, you can choose a jurisdiction that meets your requirements.
  • Price: VPS prices can vary depending on the data center location.

For Home Assistant working with devices in your home, the primary importance is a stable and sufficiently fast internet connection between your home and the VPS. Geographical proximity to your physical smart home devices is less critical, as most modern Home Assistant integrations use API calls rather than direct local access to devices, unless you are configuring specific local bridges.

Server Preparation

Before installing Home Assistant, you need to perform basic setup and secure your VPS. We will use Ubuntu Server 24.04 LTS as a stable and widely used operating system.

1. Connect via SSH

Connect to your new VPS using SSH. You will need the server's IP address and credentials (usually the root user and password, or an SSH key).


ssh root@YOUR_VPS_IP_ADDRESS

2. Create a New User and Configure Sudo

Working as the root user is unsafe. Let's create a new user and add them to the sudo group.


# Replace 'your_username' with the desired username
adduser your_username
usermod -aG sudo your_username

Now, exit the root session and log in as the new user:


exit
ssh your_username@YOUR_VPS_IP_ADDRESS

3. Configure SSH Key Authentication (Recommended)

If you are not yet using SSH keys, this is the most secure authentication method. Generate keys on your local machine if you don't have them:


# On your LOCAL machine
ssh-keygen -t ed25519 -C "[email protected]"

Copy the public key to the server:


# On your LOCAL machine
ssh-copy-id your_username@YOUR_VPS_IP_ADDRESS

After successful copying, disable password login for root and your new user. Edit the SSH server configuration file:


sudo nano /etc/ssh/sshd_config

Find and change the following lines (or add them if missing):


# Disable password login
PasswordAuthentication no
# Disable root login
PermitRootLogin no

Restart the SSH service:


sudo systemctl restart sshd

4. Update the System

Always start by updating the package database and installed packages.


sudo apt update && sudo apt upgrade -y

5. Configure Firewall (UFW)

UFW (Uncomplicated Firewall) is an easy-to-use interface for iptables. We will configure it to allow only the necessary ports.


# Install UFW if not already installed
sudo apt install ufw -y

# Allow SSH (port 22)
sudo ufw allow ssh

# Allow HTTP (port 80) and HTTPS (port 443) for web access and Let's Encrypt
sudo ufw allow http
sudo ufw allow https

# Allow Home Assistant port (usually 8123), if direct access without proxy is planned
# However, we will use Caddy as a reverse proxy, so this port can be left closed from outside
# sudo ufw allow 8123/tcp

# Enable the firewall
sudo ufw enable

Confirm that you want to proceed if UFW warns about a potential SSH connection disruption. Check the status:


sudo ufw status verbose

6. Install Fail2Ban

Fail2Ban scans logs and blocks IP addresses showing signs of malicious attacks (e.g., multiple failed SSH login attempts).


sudo apt install fail2ban -y
sudo systemctl enable fail2ban
sudo systemctl start fail2ban

Create a local configuration file for Fail2Ban so that your changes are not overwritten during package updates:


sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local

In the jail.local file, ensure that the [sshd] section is active (enabled = true) and, if desired, configure bantime (ban time) and maxretry (number of attempts).


# Example sshd section in jail.local
[sshd]
enabled = true
port = ssh
logpath = %(sshd_log)s
backend = %(sshd_backend)s
# bantime = 1d # Ban for 1 day
# maxretry = 3 # Ban after 3 failed attempts

Save changes and restart Fail2Ban:


sudo systemctl restart fail2ban

7. Install Basic Utilities

Let's install a few useful utilities that will come in handy during installation and maintenance.


sudo apt install curl wget git htop ntpdate -y

ntpdate will help synchronize system time, which is important for SSL certificates and many network services. In modern Ubuntu, systemd-timesyncd is usually already active and quite effective.


# Check time synchronization status
timedatectl status

Software Installation — Step-by-Step

Now that the server is prepared, let's proceed with installing Docker, Docker Compose, Home Assistant, and a reverse proxy with SSL.

1. Installing Docker Engine (relevant for 2026)

We will install Docker from the official Docker repository to get the latest versions.


# Update the package list
sudo apt update

# Install necessary packages to install Docker from the repository
sudo apt install ca-certificates curl gnupg lsb-release -y

# Add Docker's official GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

# Add the Docker repository to APT sources
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Update the package list with the new Docker repository
sudo apt update

# Install Docker Engine, Docker CLI, and containerd
sudo apt install docker-ce docker-ce-cli containerd.io -y

# Check Docker status
sudo systemctl status docker

Add our user to the docker group to execute Docker commands without sudo (SSH reconnection will be required).


# Replace 'your_username' with your username
sudo usermod -aG docker your_username

# Reconnect to SSH for changes to take effect
exit
ssh your_username@YOUR_VPS_IP_ADDRESS

Verify that Docker is working by running a test container:


docker run hello-world

2. Installing Docker Compose Plugin

In modern Docker versions, Docker Compose is a Docker CLI plugin. Let's install it:


sudo apt install docker-compose-plugin -y

# Check Docker Compose version
docker compose version

3. Preparing the Directory Structure for Home Assistant

Let's create a directory where Home Assistant configuration files and docker-compose.yml will be stored.


mkdir ~/homeassistant
cd ~/homeassistant

4. Creating the docker-compose.yml file for Home Assistant

Create the file docker-compose.yml. In it, we will define the Home Assistant service, its ports, volumes for data storage, and the restart policy.


nano docker-compose.yml

Insert the following content:


# Docker Compose file version
version: '3'

# Define services
services:
  homeassistant:
    # Use the official Home Assistant Core image
    # The relevant image for 2026 will be 'homeassistant/home-assistant:stable' or 'homeassistant/home-assistant:2026.x.x'
    image: homeassistant/home-assistant:stable
    # Container name
    container_name: homeassistant
    # Specify which container ports to map to the host
    # Port 8123 - standard Home Assistant port
    # We map it to local port 8123, which will only be accessible within the VPS
    # External access will be via Caddy (reverse proxy)
    ports:
      - "127.0.0.1:8123:8123"
    # Volumes for Home Assistant data storage
    # /path/to/your/config:/config - replace with the actual path on your VPS
    volumes:
      - ./config:/config
      - /etc/localtime:/etc/localtime:ro
    # Allow the container access to the host network for device discovery
    # network_mode: host # Can be used, but then port 8123 will be open on all VPS interfaces
    # It's better to use a bridge network and configure trusted_proxies in HA
    # Automatically restart the container if it stops
    restart: unless-stopped
    # Set timezone
    environment:
      TZ: Europe/Moscow # Or your timezone

Save the file (Ctrl+O, Enter, Ctrl+X).

5. Starting Home Assistant

Start the Home Assistant container using Docker Compose:


docker compose up -d

Check the container status:


docker compose ps
docker logs homeassistant

The first launch of Home Assistant may take several minutes while it loads all necessary components.

6. Installing and Configuring Caddy (Reverse Proxy with Auto-SSL)

Caddy is a powerful web server that automatically manages SSL certificates from Let's Encrypt. It is ideal for our use case.

6.1. Adding the Caddy Repository


sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update

6.2. Installing Caddy


sudo apt install caddy -y

6.3. Configuring Caddyfile

Create or edit the Caddy configuration file. Ensure you have a domain name (e.g., ha.yourdomain.com) pointing to your VPS's IP address.


sudo nano /etc/caddy/Caddyfile

Remove all existing content and insert the following, replacing ha.yourdomain.com with your actual domain:


# Your domain for Home Assistant
ha.yourdomain.com {
    # Enable automatic issuance and renewal of Let's Encrypt SSL certificate
    tls [email protected]

    # Reverse proxy to Home Assistant, running on local port 8123
    reverse_proxy 127.0.0.1:8123 {
        # Headers required for correct WebSocket operation and remote IP
        header_up Host {host}
        header_up X-Real-IP {remote_ip}
        header_up X-Forwarded-For {remote_ip}
        header_up X-Forwarded-Proto {scheme}
    }

    # Enable compression if needed (optional)
    # encode gzip zstd

    # Logging (optional)
    # log {
    #     output file /var/log/caddy/ha_access.log
    # }
}

Save the file (Ctrl+O, Enter, Ctrl+X).

6.4. Checking and Starting Caddy


# Check Caddyfile syntax
sudo caddy validate --config /etc/caddy/Caddyfile

# Restart the Caddy service to apply changes
sudo systemctl reload caddy

# Check Caddy status
sudo systemctl status caddy

Ensure Caddy has successfully started and obtained an SSL certificate. This may take a few seconds.

Configuration

After installing Home Assistant and configuring the reverse proxy, you need to perform the initial Home Assistant configuration for it to work correctly via a domain name and SSL.

1. Initial Home Assistant Setup

Open your browser and navigate to https://ha.yourdomain.com (replace with your domain). You should see the Home Assistant welcome page.

  1. Create an owner account: Enter a name, login, and password for the first user. This will be your primary administrative account.
  2. Configure location: Specify your location, timezone, and units of measurement. This is important for the correct operation of many integrations and automations (e.g., for sunrise/sunset).
  3. Device discovery: Home Assistant will attempt to automatically discover some devices on your local network. Since Home Assistant runs in Docker on a VPS, it will not directly see your home's local network. You will add devices manually or via other bridges/gateways.
  4. Complete setup: You will be directed to the Home Assistant main dashboard.

2. Home Assistant Configuration for Reverse Proxy Operation

For Home Assistant to work correctly through a reverse proxy (Caddy), you need to inform it about trusted proxies and enable the use of X-Forwarded-For headers.

Connect to your VPS and navigate to the Home Assistant configuration directory:


cd ~/homeassistant/config
nano configuration.yaml

Add the following lines to configuration.yaml:


# Home Assistant base configuration
homeassistant:
  # If you are using the domain ha.yourdomain.com
  external_url: "https://ha.yourdomain.com"
  internal_url: "http://127.0.0.1:8123" # Internal address, accessible only on the VPS

# Trusted proxies
http:
  use_x_forwarded_for: true
  # Your VPS's IP address. This is important for Home Assistant to trust requests from Caddy.
  # If Caddy is running on the same host as Home Assistant, use 172.17.0.1 (Docker bridge IP)
  # or the Docker subnet if you have a complex network configuration.
  # For simplicity, if Caddy is on the same host, you can use your VPS's IP address
  # or consider using the Docker bridge IP address.
  # On Ubuntu with Docker by default, the Docker bridge IP is often 172.17.0.1
  # You can check with the command: docker network inspect bridge
  trusted_proxies:
    - 172.17.0.0/16 # Example: entire Docker bridge subnet
    # Or a specific IP if Caddy is not in Docker or on another host:
    # - YOUR_VPS_IP_ADDRESS

Save the file (Ctrl+O, Enter, Ctrl+X).

For the changes to take effect, restart the Home Assistant container:


cd ~/homeassistant
docker compose restart homeassistant

Wait for a complete restart (1-2 minutes), then refresh the Home Assistant page in your browser.

3. Using Secrets (secrets.yaml)

For storing sensitive data such as API keys, passwords, and tokens, it is highly recommended to use a secrets.yaml file. Never store them directly in configuration.yaml.

In configuration.yaml, you reference a secret as follows:


# Example in configuration.yaml
sensor:
  - platform: template
    sensors:
      my_secret_api_key: !secret my_api_key

Then, create a secrets.yaml file in the same ~/homeassistant/config/ directory:


nano ~/homeassistant/config/secrets.yaml

And add the secret itself there:


# Example in secrets.yaml
my_api_key: "your_very_secret_key"
my_password: "my_super_password_123"

Ensure that permissions for secrets.yaml are restricted:


chmod 600 ~/homeassistant/config/secrets.yaml

4. Verifying Functionality

After all configurations, ensure that everything is working correctly:

  • HTTPS Access: Open https://ha.yourdomain.com in your browser. Ensure you see a green lock and no security warnings.
  • SSL Certificate Check: In your browser, check the certificate details (who issued it, expiration date).
  • WebSocket Connection Check: Home Assistant actively uses WebSocket. Open the developer console in your browser (F12), go to the "Network" tab, and ensure there are no WebSocket errors.
  • Home Assistant Log Check: Ensure there are no critical errors related to the network or proxy.

cd ~/homeassistant
docker compose logs homeassistant

You have successfully configured Home Assistant on a VPS with secure HTTPS access!

Backups and Maintenance

Regular backups and timely maintenance are key to the long-term stability of your smart home system. Loss of Home Assistant data can lead to the loss of all settings, automations, and device history.

1. What to Back Up

The main volume of Home Assistant data is stored in the config directory, which we mounted to the container. It contains:

  • Configuration files: configuration.yaml, secrets.yaml, and other YAML files for integrations, automations, scripts.
  • Database: Usually the home-assistant_v2.db file (SQLite) or data for an external DB (PostgreSQL, MariaDB). It stores all device state history, logs, and events.
  • Add-ons and Custom Integrations: If you are using Home Assistant Core without Supervisor, add-ons are installed separately. Custom integrations are usually located in the custom_components directory.
  • Media files: If Home Assistant is used for storing images or other media.

Also, don't forget about Caddy's configuration: /etc/caddy/Caddyfile.

2. Simple Restic Auto-Backup Script

Restic is a modern, fast, and secure backup program. It supports deduplication, encryption, and multiple backends (S3, SFTP, local disk).

2.1. Restic Installation


# Загрузка последней версии Restic (актуально для 2026)
# Проверьте страницу релизов Restic на GitHub для последней версии
wget https://github.com/restic/restic/releases/download/v0.16.4/restic_0.16.4_linux_amd64.bz2 -O restic.bz2
bzip2 -d restic.bz2
sudo mv restic /usr/local/bin/restic
sudo chmod +x /usr/local/bin/restic

2.2. Initializing the Restic Repository

We will use an external S3-compatible backend (e.g., MinIO, Wasabi, Backblaze B2, or AWS S3). Create a bucket and obtain access keys.


# Установите переменные окружения для S3
export AWS_ACCESS_KEY_ID="ВАШ_S3_КЛЮЧ_ДОСТУПА"
export AWS_SECRET_ACCESS_KEY="ВАШ_S3_СЕКРЕТНЫЙ_КЛЮЧ"
export RESTIC_REPOSITORY="s3:s3.your-s3-provider.com/ваш-бакет-для-ha" # Замените на ваш S3-эндпоинт и бакет
export RESTIC_PASSWORD="ВАШ_НАДЕЖНЫЙ_ПАРОЛЬ_ДЛЯ_РЕПОЗИТОРИЯ_RESTIC"

# Инициализируем репозиторий Restic
restic init

Important: Record RESTIC_PASSWORD in a safe place!

2.3. Creating the Backup Script

Create the backup_ha.sh file in your user's home directory:


nano ~/backup_ha.sh

Insert the following content, replacing variables with your values:


#!/bin/bash

# Переменные окружения для Restic
export AWS_ACCESS_KEY_ID="ВАШ_S3_КЛЮЧ_ДОСТУПА"
export AWS_SECRET_ACCESS_KEY="ВАШ_S3_СЕКРЕТНЫЙ_КЛЮЧ"
export RESTIC_REPOSITORY="s3:s3.your-s3-provider.com/ваш-бакет-для-ha"
export RESTIC_PASSWORD="ВАШ_НАДЕЖНЫЙ_ПАРОЛЬ_ДЛЯ_РЕПОЗИТОРИЯ_RESTIC"

# Директории для бэкапа
HA_CONFIG_DIR="/home/ваш_пользователь/homeassistant/config"
CADDY_CONFIG_FILE="/etc/caddy/Caddyfile"

# Логирование
LOG_FILE="/var/log/ha_backup.log"

# Функция для логирования
log_message() {
  echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | sudo tee -a "$LOG_FILE"
}

log_message "Starting Home Assistant backup..."

# Остановка Home Assistant перед бэкапом БД (для консистентности)
# Если вы используете внешнюю БД, этот шаг может быть не нужен или должен быть адаптирован
cd /home/ваш_пользователь/homeassistant
docker compose stop homeassistant
log_message "Home Assistant container stopped."

# Выполнение бэкапа
restic backup \
  "$HA_CONFIG_DIR" \
  "$CADDY_CONFIG_FILE" \
  --verbose \
  --tag "homeassistant-daily" \
  --exclude-file "$HA_CONFIG_DIR/.gitignore" \
  --exclude ".log" \
  --exclude ".sqlite-journal" \
  --exclude "__pycache__" \
  --exclude ".storage" \
  --host "vps-$(hostname)" 2>&1 | sudo tee -a "$LOG_FILE"

# Удаление старых бэкапов (политика: хранить 7 последних ежедневных, 4 еженедельных, 12 ежемесячных, 1 ежегодный)
restic forget \
  --prune \
  --tag "homeassistant-daily" \
  --keep-daily 7 \
  --keep-weekly 4 \
  --keep-monthly 12 \
  --keep-yearly 1 2>&1 | sudo tee -a "$LOG_FILE"

# Запуск Home Assistant после бэкапа
docker compose start homeassistant
log_message "Home Assistant container started."

log_message "Backup finished."

Make the script executable:


chmod +x ~/backup_ha.sh

2.4. Adding the Script to Cron

Let's set up the daily backup script to run at 3 AM.


crontab -e

Add the following line to the end of the file:


0 3   * /home/ваш_пользователь/backup_ha.sh > /dev/null 2>&1

Note: Ensure that Restic's environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, RESTIC_REPOSITORY, RESTIC_PASSWORD) are either written directly into the backup_ha.sh script or are available through the user profile under which cron runs (which is more complex). It's easiest to insert them directly into the script.

Also, ensure that the user ваш_пользователь has write permissions to /var/log/ha_backup.log (or change the log path).

3. Where to Store Backups

As shown above, it is recommended to use an external S3-compatible service for storing backups. This ensures geographical distance and high availability of data, which is critically important in case of VPS failure.

  • S3-compatible storage: Backblaze B2, Wasabi, Amazon S3, DigitalOcean Spaces, Linode Object Storage.
  • Another VPS: You can configure Restic to back up to another VPS via SFTP if you have a second server.

4. Updates: Rolling vs Maintenance Window

Regular updates are important for security and new features.

  • Home Assistant Update:

    Home Assistant releases updates approximately once a month. To update the Docker container:

    
    cd ~/homeassistant
    docker compose pull homeassistant # Downloads new image
    docker compose up -d homeassistant # Stops old, starts new
    

    It is recommended to perform this during a "maintenance window" when you can monitor the process and quickly resolve potential issues. It is recommended to make a backup before updating.

  • OS and Docker Update:

    Regularly update the operating system and Docker Engine:

    
    sudo apt update && sudo apt upgrade -y
    

    This is also best done during a maintenance window, as some kernel or Docker updates may require a VPS reboot.

  • Caddy Update:

    Caddy updates along with system packages if you used a repository:

    
    sudo apt update && sudo apt upgrade -y
    sudo systemctl reload caddy # After update
    

Troubleshooting + FAQ

Home Assistant does not start or returns a 502 Bad Gateway error

What to check:

  1. Home Assistant Docker container logs: Check that the Home Assistant container is running and there are no critical errors in its logs.
  2. Container status: Make sure the Home Assistant container is in the "running" state.
  3. Caddy logs: If Caddy returns 502, it means it cannot reach Home Assistant. Check Caddy logs for connection errors.
  4. Home Assistant port availability: Make sure Home Assistant is listening on port 8123 inside the VPS (curl http://127.0.0.1:8123).

How to fix:


cd ~/homeassistant
docker compose ps # Check status
docker compose logs homeassistant # Check HA logs
sudo journalctl -u caddy --no-pager # Check Caddy logs

If there are configuration errors in the Home Assistant logs, correct configuration.yaml and restart the container. If Caddy cannot connect, check the port in Caddyfile and make sure Home Assistant is indeed listening on 127.0.0.1:8123.

No HTTPS access or SSL error

What to check:

  1. DNS record: Make sure your A-record for the domain (e.g., ha.yourdomain.com) correctly points to your VPS's IP address. Use dig ha.yourdomain.com or nslookup ha.yourdomain.com.
  2. Firewall (UFW): Make sure ports 80 (HTTP) and 443 (HTTPS) are open. Let's Encrypt uses port 80 for domain verification.
  3. Caddy logs: Caddy automatically tries to obtain an SSL certificate. Check its logs for errors related to Let's Encrypt.
  4. Caddyfile syntax: An error in the Caddyfile configuration can prevent it from starting or obtaining a certificate.

How to fix:


sudo ufw status verbose # Check UFW status
sudo journalctl -u caddy --no-pager # Check Caddy logs
sudo caddy validate --config /etc/caddy/Caddyfile # Check Caddyfile syntax

If the problem is with DNS, wait for the records to update. If with UFW, open the ports. If with Caddy, correct the Caddyfile and restart with sudo systemctl reload caddy.

Problems with integrations or device discovery

What to check:

  1. Docker network settings: By default, Home Assistant in Docker is in an isolated network. This means it cannot directly "see" devices on your home local network.
  2. Home Assistant settings: Make sure all integrations are configured with the correct credentials and IP addresses/hosts.
  3. Firewall on VPS: If you are trying to connect to devices in your home via VPN or another complex network, make sure the firewall on the VPS is not blocking these connections.

How to fix:

For local device discovery, you will need to set up a VPN tunnel (e.g., WireGuard) between your VPS and your home network so that Home Assistant can "see" local IP addresses. Alternatively, use an MQTT broker as an intermediary, or cloud integrations if supported by your devices.

What is the minimum suitable VPS configuration?

The minimum recommended configuration for Home Assistant on a VPS is 2 CPU cores, 4 GB RAM, and an 80 GB SSD. This is sufficient for a small smart home system (up to 20-30 devices) with basic automations and data history. However, if you plan to actively use cameras, complex scripts, voice assistants, or store long-term history, it is recommended to increase resources to 4 CPU cores, 8 GB RAM, and 160 GB SSD for more comfortable operation and future headroom.

What to choose — VPS or dedicated for this task?

For most users, Home Assistant on a VPS is the optimal choice. It offers sufficient performance, flexibility, and reliability at a more affordable price than a dedicated server. A dedicated server should only be considered in very specific cases: if you have hundreds of devices, many IP cameras with video analytics, you plan to run dozens of other resource-intensive services on the same server, or you need full hardware control for specific tasks (e.g., with a GPU). In 95% of cases, a VPS will be more than sufficient.

How to update Home Assistant?

To update Home Assistant running in Docker, navigate to the directory containing your docker-compose.yml (e.g., ~/homeassistant) and execute the following commands:


docker compose pull homeassistant # Downloads the latest stable version of the Home Assistant image
docker compose up -d homeassistant # Stops the current container and starts a new one with the updated image

Always back up your configuration before updating.

How to migrate Home Assistant to a new server?

Migrating Home Assistant deployed with Docker Compose is relatively straightforward. You need to:

  1. Create a full backup of your current ~/homeassistant/config directory.
  2. Copy this backup to the new server.
  3. Install Docker and Docker Compose on the new server.
  4. Create the directory structure and docker-compose.yml file as described in this guide.
  5. Unpack the backup into the ~/homeassistant/config directory on the new server.
  6. Start Home Assistant using docker compose up -d.
  7. Configure DNS and Caddy on the new server.

This highlights the advantage of Docker: all dependencies are encapsulated, and migration boils down to copying data and Docker configuration.

Home Assistant performance issues

What to check:

  1. VPS resource usage: Use htop, docker stats to monitor CPU, RAM, and disk I/O.
  2. Database size: A large Home Assistant database (home-assistant_v2.db) can slow down performance.
  3. Number of integrations and automations: Too many active integrations or unoptimized automations can consume resources.

How to fix:

If the VPS is overloaded, consider upgrading resources. To optimize the database, configure recorder in configuration.yaml to exclude unnecessary entities from recording or limit data retention. Analyze your automations for cyclical or resource-intensive tasks. It might be possible to offload some integrations to separate devices (e.g., Zigbee2MQTT on a Raspberry Pi).

Conclusion and Next Steps

Congratulations! You have successfully installed and configured Home Assistant on your VPS using Docker and secure HTTPS access. You now have a fully controlled, private, and scalable platform for managing your smart home, accessible from anywhere in the world. This solution gives you maximum flexibility and independence from third-party services.

Here are some next steps to help you make the most of your new system:

  • Device Integration: Start adding your smart devices and services to Home Assistant. Explore the official Home Assistant documentation on integrations.
  • Creating Automations: Use Home Assistant's powerful automation tools to create scenarios that will make your home smarter and more comfortable.
  • Exploring Add-ons and Custom Integrations: Extend your system's functionality with the Home Assistant community by exploring available add-ons and custom components.
  • Monitoring and Optimization: Continue to monitor your VPS resources, optimize the database and automations to ensure stable and fast system operation.

Was this guide helpful?

Install Home Assistant on VPS: Complete Guide with Docker and SSL
support_agent
Valebyte Support
Usually replies within minutes
Hi there!
Send us a message and we'll reply as soon as possible.