Home Assistant with ngrok
To put your Home Assistant instance online with ngrok:
- Start Home Assistant locally in a Docker container
- Add ngrok to the Docker container
- Allow trusted proxies in Home Assistant
This guide covers how to set up Home Assistant with ngrok. This combination lets you access your Home Assistant dashboard over the public internet.
Prerequisites:
- Docker Desktop
- Docker Compose
- ngrok installed on your machine
- Basic familiarity with the command line
Tip: This guide walks through setting up Home Assistant in a Docker container from scratch, but the same principles apply if you already have a Home Assistant instance set up, or if you set it up using one of their other installation methods.
Step 1: Initial setup
-
Create a directory called
home-assistant
-
Inside the
home-assistant
directory:
- create your Docker Compose file called
compose.yaml
- create a directory called
config
Step 2: Run Home Assistant in a Docker container
- Update
compose.yaml
:
Loading…
- In your terminal, start a Docker container with this compose.yaml file:
Loading…
- Visit localhost:8123 in your browser. You should see your Home Assistant login page:
Step 3: Add ngrok
- Add ngrok to your
compose.yaml
under the services section:
Loading…
- In your terminal, restart your Docker container with this compose.yaml file:
Loading…
-
Visit your ngrok dashboard to see the endpoint URL:
-
If you visit the ngrok URL, you'll get a 4xx response:
and an error log line your Docker Desktop logs for the Home Assistant container:
Loading…
That's because we still have to update the Home Assistant configuration to allow trusted proxies.
Step 3: Allow trusted proxies in Home Assistant
- In your
/home-assistant/config
directory, look for the file calledconfiguration.yaml
. By default, it should already have these settings:
Loading…
Add this new section to the bottom:
Loading…
-
Restart the Docker container so the updated Home Assistant configuration can take effect.
-
Visit your ngrok endpoint URL and see your Home Assistant instance online!