How to Install Home Assistant on Ubuntu Server
Take control of your smart home with a self-hosted automation platform
![]()
![]()
![]()
![]()
Tired of cloud-dependent smart home platforms that go offline when the internet drops? Want complete control over your home automation without monthly fees or privacy concerns?
Home Assistant gives you local control over all your smart devices, powerful automation capabilities, and works even when your internet is down. Best of all, itâs completely free and open source.
Letâs get it installed.
What is Home Assistant?
Home Assistant is an open-source home automation platform that runs locally on your hardware. It connects to hundreds of different smart home devices and services, giving you one unified interface to control everything.
What makes it special:
-
Local control - Your home, your hardware, your data
-
Works offline - Internet down? Your automations keep running
-
Device agnostic - Supports 2,000+ integrations (lights, cameras, thermostats, sensors, etc.)
-
Powerful automations - Control your home based on time, conditions, or events
-
No monthly fees - Free forever, no subscriptions required
What Youâll Need
Prerequisites
Required:
-
Ubuntu Server installed and fully updated (20.04 LTS, 22.04 LTS, or 24.04 LTS)
-
SSH access to your server
-
Root or sudo privileges
-
At least 2GB RAM (4GB recommended)
-
20GB available disk space (60GB recommended for recordings and history)
Network Requirements:
-
Static IP address for your server (set in your routerâs DHCP settings)
-
Port 8123 available for Home Assistant web interface
Optional but Recommended:
-
Domain name or DuckDNS subdomain for external access
-
SSL certificate for HTTPS (can set up later)
Time Required:
-
Fresh install: 30-45 minutes
-
Add integrations and configure: varies by complexity
Installation Overview
Weâll be installing Home Assistant using Docker because it:
-
Makes updates simple
-
Keeps Home Assistant isolated from your system
-
Works on any Ubuntu version
-
Makes backup and restore easy
Hereâs what weâll do:
-
Update your system
-
Install Docker
-
Set up firewall rules
-
Create Home Assistant directory structure
-
Deploy Home Assistant with Docker Compose
-
Access and configure the web interface
Step 1: Update Your System
First, make sure your Ubuntu installation is fully updated.
# Update package lists and upgrade all packages
sudo apt update && sudo apt -y full-upgrade
# Remove unnecessary packages
sudo apt -y autoremove --purge && sudo apt -y autoclean
If the kernel was updated, reboot:
sudo reboot
Wait about 60 seconds, then SSH back into your server.
Step 2: Install Docker
Docker is the foundation for running Home Assistant in a container.
Install Prerequisites
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg lsb-release
Add Dockerâs Official GPG Key
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
Add Docker Repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Configure Docker Permissions
Add your user to the docker group so you donât need sudo for every docker command:
sudo usermod -aG docker $USER
Enable Docker to Start on Boot
sudo systemctl enable docker
sudo systemctl start docker
Verify Docker Installation
sudo docker run hello-world
You should see a message confirming Docker is working correctly.
Important: Log out and log back in for the docker group membership to take effect:
exit
Then SSH back in and verify you can run docker without sudo:
docker ps
You should see an empty list of containers (no error message).
Step 3: Configure Firewall
Secure your server while allowing Home Assistant access.
Enable UFW Firewall
sudo ufw enable
Type y when prompted.
Set Default Policies
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw default deny routed
Allow SSH (Critical - Donât Lock Yourself Out!)
Replace 192.168.1.0/24 with your actual network subnet:
sudo ufw allow from 192.168.1.0/24 to any port 22 proto tcp comment 'SSH from LAN'
How to find your network subnet:
-
If your serverâs IP is
192.168.1.50, your subnet is192.168.1.0/24 -
If your serverâs IP is
192.168.0.100, your subnet is192.168.0.0/24 -
If your serverâs IP is
10.0.0.25, your subnet is10.0.0.0/24
Allow Home Assistant Web Interface
sudo ufw allow from 192.168.1.0/24 to any port 8123 proto tcp comment 'Home Assistant Web UI'
Again, replace 192.168.1.0/24 with your network subnet.
Verify Firewall Rules
sudo ufw status verbose
You should see:
-
Default policies (deny incoming, allow outgoing)
-
SSH allowed from your LAN
-
Port 8123 allowed from your LAN
Step 4: Create Directory Structure
Home Assistant needs a place to store its configuration files.
# Create config directory
sudo mkdir -p /opt/homeassistant/config
# Set ownership to your user
sudo chown -R $USER:$USER /opt/homeassistant
Step 5: Create Docker Compose File
Docker Compose lets you define and manage your Home Assistant container with a simple configuration file.
nano /opt/homeassistant/docker-compose.yml
Add this content:
version: '3'
services:
homeassistant:
container_name: homeassistant
image: ghcr.io/home-assistant/home-assistant:stable
volumes:
- /opt/homeassistant/config:/config
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
privileged: true
network_mode: host
What this does:
-
container_name: Names the container âhomeassistantâ -
image: Uses the official Home Assistant stable release -
volumes: Maps config directory and syncs system time -
restart: Automatically restarts if crashed or after reboot -
privileged: Gives Home Assistant access to hardware (needed for some integrations) -
network_mode: host: Uses your serverâs network directly (simplifies setup)
Save and exit: Press Ctrl+O, then Enter, then Ctrl+X.
Step 6: Start Home Assistant
cd /opt/homeassistant
docker compose up -d
The -d flag runs it in detached mode (background).
Wait 2-3 minutes for Home Assistant to fully start. First startup takes longer as it downloads dependencies and initializes the database.
Step 7: Verify Home Assistant is Running
Check Container Status
docker ps
You should see a container named homeassistant with status Up.
Check Logs
docker logs homeassistant
Look for messages indicating Home Assistant is starting. Youâll see lots of output. Near the end, you should see something like:
INFO (MainThread) [homeassistant.core] Starting Home Assistant
INFO (MainThread) [homeassistant.bootstrap] Home Assistant initialized in X.XXs
If you see errors, wait another minute and check again. First startup can take 3-5 minutes on slower hardware.
Step 8: Access Home Assistant Web Interface
Open your web browser and navigate to:
http://YOUR_SERVER_IP:8123
Replace YOUR_SERVER_IP with your serverâs actual IP address. For example:
http://192.168.1.50:8123
First-time Setup Wizard:
- Create Admin Account
-
Choose a username
-
Create a strong password
-
Enter your name (can be anything)
- Set Your Location
-
Enter your home address or move the map pin
-
This sets your timezone and enables location-based automations
-
Choose your unit system (Imperial/Metric)
- Share Analytics (Optional)
-
Choose whether to share anonymous usage data with Home Assistant
-
This helps developers improve the platform
-
Your choice wonât affect functionality
- Finish Setup
-
Click âFinishâ
-
Youâll see the Home Assistant dashboard
Step 9: Basic Configuration
Set a Static IP (If Not Already Done)
If your server doesnât have a static IP, set one in your routerâs DHCP settings to prevent the IP from changing. Look for âDHCP Reservationâ or âStatic DHCPâ in your routerâs admin interface.
Configure Time Zone (If Needed)
Home Assistant should auto-detect your timezone, but verify:
-
Click Settings (gear icon in sidebar)
-
Click System
-
Click General
-
Verify Time Zone is correct
-
Click Save if you made changes
Step 10: Install Your First Integration
Letâs test Home Assistant by adding a simple integration.
-
Click Settings (gear icon)
-
Click Devices & Services
-
Click + ADD INTEGRATION (bottom right)
-
Search for âSunâ
-
Click Sun in the results
-
Click Submit
The Sun integration tracks sunrise/sunset times based on your location. Youâll now see a sun entity on your dashboard showing whether itâs day or night.
Other beginner-friendly integrations to try:
-
Weather: Get local weather forecasts
-
Speedtest: Monitor your internet speed
-
System Monitor: Track your serverâs CPU, memory, and disk usage
Managing Home Assistant
View Logs
docker logs homeassistant
Follow logs in real-time:
docker logs -f homeassistant
Press Ctrl+C to stop following.
Restart Home Assistant
From Web Interface:
-
Go to Settings > System
-
Click Restart (top right)
-
Choose Restart Home Assistant
From Command Line:
cd /opt/homeassistant
docker compose restart
Stop Home Assistant
cd /opt/homeassistant
docker compose down
Start Home Assistant
cd /opt/homeassistant
docker compose up -d
Update Home Assistant
cd /opt/homeassistant
docker compose pull
docker compose up -d
This pulls the latest stable image and recreates the container. Your configuration is preserved in /opt/homeassistant/config.
Backup Your Configuration
Create a manual backup:
cd /opt/homeassistant
sudo tar -czf ~/ha-backup-$(date +%Y%m%d).tar.gz config/
This creates a timestamped backup file in your home directory.
Restore from backup:
cd /opt/homeassistant
sudo tar -xzf ~/ha-backup-YYYYMMDD.tar.gz
docker compose restart
Replace YYYYMMDD with your backup date.
Automated backups can be configured later using Home Assistantâs built-in backup feature or external backup tools.
Troubleshooting
Home Assistant Wonât Start
Check container logs:
docker logs homeassistant
Look for error messages. Common issues:
-
Port 8123 already in use
-
Permission issues with config directory
-
Corrupted configuration file
Verify Docker is running:
sudo systemctl status docker
Canât Access Web Interface
Check if container is running:
docker ps
If you donât see homeassistant, start it:
cd /opt/homeassistant
docker compose up -d
Check firewall:
sudo ufw status verbose
Make sure port 8123 is allowed from your network.
Check if port 8123 is listening:
sudo netstat -tlnp | grep 8123
You should see something like:
tcp6 0 0 :::8123 :::* LISTEN 12345/python3
If not, Home Assistant isnât running properly. Check logs.
Try from server itself:
curl http://localhost:8123
If this works but you canât access from another computer, itâs a firewall/network issue.
Configuration Errors
If you edited configuration files and Home Assistant wonât start:
-
Check the logs for specific error messages
-
Validate your YAML syntax (indentation matters!)
-
Restore from backup if needed
Common YAML mistakes:
-
Using tabs instead of spaces
-
Incorrect indentation
-
Missing colons
-
Smart quotes instead of straight quotes
Out of Disk Space
Check disk usage:
df -h /opt/homeassistant
Clean up old logs and database:
Home Assistant stores history in an SQLite database that can grow large over time. You can purge old data from the web interface:
-
Go to Settings > System > Storage
-
Adjust history retention
-
Click Purge
Or limit retention in /opt/homeassistant/config/configuration.yaml:
recorder:
purge_keep_days: 7
Then restart Home Assistant.
Next Steps
Now that Home Assistant is running, hereâs what to explore next:
1. Add Devices and Integrations
Home Assistant supports thousands of devices. Popular categories:
-
Lights: Philips Hue, LIFX, TP-Link, Yeelight
-
Cameras: Most IP cameras, webcams
-
Smart Plugs: TP-Link, Wemo, Sonoff
-
Thermostats: Nest, Ecobee, Honeywell
-
Voice Assistants: Google Home, Alexa
-
Media Players: Roku, Chromecast, Plex, Spotify
Browse integrations at Settings > Devices & Services > Add Integration.
2. Create Automations
Automations are what make your smart home actually smart. Examples:
-
Turn on lights at sunset
-
Send notification when door opens
-
Adjust thermostat based on occupancy
-
Turn off everything when you leave
Start simple and build complexity over time.
3. Set Up External Access
Access Home Assistant from anywhere:
-
Set up a reverse proxy with SSL (recommended)
-
Use Home Assistant Cloud (paid, easiest)
-
Use a VPN to your network (most secure)
External access requires proper security measures. Research before exposing Home Assistant to the internet.
4. Install Add-ons and HACS
Home Assistant has an add-on ecosystem for extended functionality. Youâll need to switch to Home Assistant Supervised or Home Assistant OS to use official add-ons, but you can install HACS (Home Assistant Community Store) for custom integrations:
Visit: https://hacs.xyz/
5. Explore Dashboards
Customize your interface:
-
Create multiple dashboards for different rooms or users
-
Add cards for quick access to common controls
-
Use custom card designs from the community
6. Join the Community
Home Assistant has an active community:
-
Discord: Home Assistant
-
Documentation: Documentation - Home Assistant
Security Best Practices
Change Default Ports (Optional)
If exposing Home Assistant to the internet, consider changing from port 8123 to something non-standard.
Edit docker-compose.yml:
ports:
- "8123:8123"
Change to:
ports:
- "12345:8123"
Then restart:
docker compose down
docker compose up -d
Access on new port: http://YOUR_IP:12345
Enable Two-Factor Authentication
-
Go to your profile (click your name, bottom left)
-
Scroll to Two-factor Authentication
-
Follow setup instructions
Use Strong Passwords
Generate a secure password:
openssl rand -base64 32
Save it in a password manager.
Regular Updates
Check for updates monthly:
cd /opt/homeassistant
docker compose pull
docker compose up -d
Network Isolation (Advanced)
Consider putting IoT devices on a separate VLAN to isolate them from your main network. This is beyond the scope of this guide but worth researching for enhanced security.
Performance Tips
Reduce Database Size
Limit what gets recorded:
Edit /opt/homeassistant/config/configuration.yaml:
recorder:
purge_keep_days: 7
exclude:
domains:
- automation
- updater
entities:
- sensor.weather_temperature
Use MariaDB Instead of SQLite (Advanced)
For larger installations, switching to MariaDB improves performance. This requires running a separate database container. Research this once you have hundreds of entities.
Monitor Resource Usage
From Home Assistant, install the System Monitor integration to track:
-
CPU usage
-
Memory usage
-
Disk space
-
Network activity
Complete - Youâre Done!
You now have a fully functional Home Assistant installation running on Ubuntu Server.
What youâve accomplished:
-
Installed Docker -
Configured firewall security -
Deployed Home Assistant -
Set up basic configuration -
Learned management commands
Your Home Assistant is:
-
Running 24/7
-
Accessible from your local network
-
Ready to integrate with smart home devices
-
Automatically restarting after reboots or crashes
Start adding devices, creating automations, and taking control of your smart home.
Questions or Issues?
Run into problems during installation? Have questions about integrations or automations?
Drop a comment below. Letâs troubleshoot together.