Home Assistant is the best-known open-source platform for your smart home: Bring lights, heating, sensors, and cloud services together in one interface and build automations across all manufacturers. In this guide, you’ll install Home Assistant with Docker (the “Home Assistant Container” option) using Docker Compose on your Linux VPS, secure access with HTTPS, and connect devices in your home over a VPN.
Skip the Docker setup: Home Assistant is also available as a one-click app. The VPS automatically configures the domain and SSL certificate. See Rent a Home Assistant VPS.
Home Assistant usually runs on a small device at home, such as a Raspberry Pi or a NAS. A VPS in a data center is a good fit if:
- Cloud integrations are your priority, such as devices already controlled through the manufacturers’ clouds, weather data, calendars, or notifications.
- You want your dashboards and automations to be accessible at all times, regardless of a power outage, DSL disruption, or a crash on your home Raspberry Pi.
- You don’t want to run your own device and prefer fixed resources and backups from your hosting provider.
- You’re bringing multiple locations together, such as your home and vacation house, both connected to the server over a VPN.
A VPS is less suitable if you mainly control radio devices directly (Zigbee, Z-Wave, Thread, Bluetooth) and need your automations to work without an internet connection. You can’t connect a USB radio stick to a server in a data center. See “Connecting devices at home” for how to integrate radio devices anyway.
Home Assistant offers several installation methods. This guide uses Home Assistant Container: Home Assistant runs as a Docker container alongside your other services on the VPS.
| Home Assistant Container | Home Assistant OS | |
|---|---|---|
| Installation | Docker container on your Linux system | Dedicated operating system for the entire server |
| Add-ons from the add-on store | No | Yes |
| Additional services (MQTT, Zigbee2MQTT, Node-RED) | As separate containers | As add-ons |
| Updates | Using docker compose pull | Through the interface |
| Other services on the same server | Yes | No |
This guide doesn’t cover Home Assistant OS. The only thing missing from the container version is add-ons; all integrations and automations work just the same.
- A Linux VPS running Debian or Ubuntu with SSH access. See First access via SSH.
- Docker and Docker Compose. See Install Docker. Check the installation with
docker --versionanddocker compose version. - For HTTPS: a domain or subdomain whose A record points to your VPS’s IP address (e.g.,
ha.example.com).
These resources are sufficient for Home Assistant with a few dozen devices:
| Hardware | Minimum | Recommended |
|---|---|---|
| CPU | 1 vCPU core | 2 vCPU cores |
| RAM | 2 GB | 4 GB |
| Storage | 20 GB | 40 GB |
You’ll need more RAM and storage if you have many devices, keep a long history, or run additional services such as MQTT and Node-RED on the same server.
Home Assistant is accessible without an account as soon as it starts: The first person to open the page can create the administrator account. So block port 8123 before starting the container. Here’s how to do that with ufw:
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
This keeps port 8123 blocked from the outside. You’ll make the first connection through an SSH tunnel and access Home Assistant over HTTPS afterward. Learn more in Managing the firewall on Linux.
Create a directory for Home Assistant and switch to it:
mkdir -p /opt/homeassistant
cd /opt/homeassistant
Create the Compose file using nano docker-compose.yml:
services:
homeassistant:
container_name: homeassistant
image: ghcr.io/home-assistant/home-assistant:stable
volumes:
- ./config:/config
- /etc/localtime:/etc/localtime:ro
environment:
- TZ=Europe/Berlin
network_mode: host
restart: unless-stopped
Here’s what the entries mean:
image: the official Home Assistant image, using thestablechannel../config:/config: all settings, automations, and the database are stored in the/opt/homeassistant/configdirectory on your VPS.network_mode: host: Home Assistant uses the server’s network directly. This lets it reach devices over the VPN later, and the server firewall applies without any Docker exceptions.restart: unless-stopped: the container starts automatically after the VPS restarts.
The official guide also uses privileged: true and /run/dbus. You only need these for USB and Bluetooth devices connected to the server. Leave both out on a VPS.
Start the container:
docker compose up -d
Check whether it’s running with docker compose ps and view the logs with docker compose logs -f.
Because port 8123 is blocked, you’ll open the interface through an SSH tunnel the first time. Run this on your own computer:
ssh -L 8123:localhost:8123 root@SERVER_IP
Replace SERVER_IP with your VPS’s IP address. Then open http://localhost:8123 in your browser. Home Assistant will guide you through setup: create an account, choose a location and time zone, and add your first integrations. Then close the tunnel.
To access Home Assistant remotely, put a reverse proxy with an SSL certificate in front of it. For the basics, see Set up a reverse proxy with nginx and Create an SSL certificate (Let's Encrypt).
For Home Assistant, the proxy must forward WebSockets, or the interface won’t load completely. Here’s an nginx server block:
server {
listen 80;
server_name ha.example.com;
location / {
proxy_pass http://127.0.0.1:8123;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Then obtain the certificate with certbot --nginx -d ha.example.com. Certbot adds HTTPS and HTTP redirection to the block.
To allow Home Assistant to accept requests from the proxy, add this to /opt/homeassistant/config/configuration.yaml:
http:
use_x_forwarded_for: true
trusted_proxies:
- 127.0.0.1
- ::1
Restart Home Assistant with docker compose restart. Without this entry, Home Assistant responds through the proxy with 400: Bad Request and logs a message about the reverse proxy.
Using Caddy instead of nginx is simpler: Caddy obtains the certificate itself and forwards WebSockets automatically. An entry like ha.example.com { reverse_proxy 127.0.0.1:8123 } in the Caddyfile is all you need. The http entry in configuration.yaml is still required.
Then enable two-factor authentication for your account in Home Assistant (Profile > Security). Find more tips for securing your server in Linux security tips.
Everything that makes up Home Assistant is stored in the /opt/homeassistant/config directory: settings, automations, dashboards, and history. Back up this directory to back up the entire installation. You have two options:
- In Home Assistant: Go to Settings > System > Backups to create backups directly in the interface, including automatic scheduled backups.
- On the server: Briefly stop the container and archive the directory:
cd /opt/homeassistant
docker compose stop
tar -czf ha-backup-$(date +%F).tar.gz config
docker compose start
Download the backup regularly or also use your VPS backups in the web interface. To restore, put the config directory back and restart the container.
New versions are released every month. To update:
cd /opt/homeassistant
docker compose pull
docker compose up -d
Back up the config directory first and read the “Backward-incompatible changes” section in the release notes. Remove old images afterward with docker image prune.
Your VPS is in a data center, while your devices are at home. To let Home Assistant reach them, connect both networks over a VPN. The easiest option is WireGuard: the VPS acts as the VPN server, and a device at your home connects to it.
Install WireGuard on the VPS and generate a key pair:
apt install wireguard
wg genkey | tee /etc/wireguard/server.key | wg pubkey > /etc/wireguard/server.pub
Create the /etc/wireguard/wg0.conf file. Set SERVER_PRIVATE_KEY to the contents of /etc/wireguard/server.key, set HOME_PUBLIC_KEY to the public key of the device at your home, and replace 192.168.178.0/24 with your home network:
[Interface]
Address = 10.8.0.1/24
ListenPort = 51820
PrivateKey = SERVER_PRIVATE_KEY
[Peer]
# Router oder Gerät bei dir zu Hause
PublicKey = HOME_PUBLIC_KEY
AllowedIPs = 10.8.0.2/32, 192.168.178.0/24
Open the port and start the connection:
ufw allow 51820/udp
systemctl enable --now wg-quick@wg0
On the home side, you have two options:
- A router with WireGuard: Many routers, such as the FRITZ!Box running FRITZ!OS 7.50 or later, can establish a WireGuard connection to another network themselves. Enter the VPS’s public key, its IP address with port
51820, and the10.8.0.0/24network there. - A small device on your home network, such as a Raspberry Pi, configured as a WireGuard client with
PersistentKeepalive = 25. The device forwards requests to your home network; this requires IP forwarding and a route for10.8.0.0/24on your router.
Once the connection is up, Home Assistant can reach your devices using their local IP addresses. Prefer OpenVPN? That works too. See Install OpenVPN.
- Automatic device discovery: mDNS, SSDP, and broadcasts don’t travel over the VPN. Devices won’t appear automatically; add them in the integration using their IP address.
- Radio devices (Zigbee, Z-Wave, Thread, Bluetooth): These need a nearby radio coordinator. Use a network-enabled Zigbee coordinator (over LAN or Wi-Fi) that Home Assistant can reach over the VPN, or a device at home running Zigbee2MQTT that sends the data to your server over MQTT.
- No control without an internet connection: If your home connection goes down, automations for those devices won’t work either. For an alarm system, heating, or blinds that must always work, a local installation at home is a better choice.
You’ve installed Home Assistant with Docker on your VPS, secured access over HTTPS, and connected your home network over a VPN. Add services such as an MQTT broker or Node-RED as additional services in the same docker-compose.yml.
Prefer to skip the Docker setup? Install Home Assistant as a one-click app. See One-click apps and Rent a Home Assistant VPS.