Home Assistant Remote Access with DuckDNS and Let’s Encrypt - Kiril Peyanski's Blog (2024)

You may want to have Home Assistant remote access from everywhere, but you don’t want to setup complicated VPNs or to pay for the cloud service? If yes, then this article is just for you.

Table of Contents

What will you see in this article?

Exposing a local server or service to the outside world has always been tricky.

Exposing Home Assistant is not hard, but you have to do it the right way with SSL encryption and IP ban enabled for multiple failed logins. Otherwise you put your whole house or at least all of your sensors, switches and integrations that you have in Home Assistant at risk.

This tutorial will take you through some port forwarding, setup a dynamic DNS for your IP and allow trusted encrypted connections – using DuckDNS and Let’s Encrypt for free!

And if you wouldn’t mind just hitting that little “subscribe” button for my Newsletter. That will greatly help me and by the way it is also free.
Now let’s start this article.

Home Assistant Port Forwarding

First step of the enabling Home Assistant remote access is to set up a port forwarding rule in your router. Just search for: ”[your router] port forward” in YouTube or in Google.

Here is how you can do it in UniFi controller.

Go to Settings > Routing & Firewall > Port Forwarding in your UniFi Controller interface and click on Create New Port Forward Rule button.

Home Assistant Remote Access with DuckDNS and Let’s Encrypt - Kiril Peyanski's Blog (1)

This is what you aim! Just replace the Forward IP10.0.0.2 with your Home Assistant local address and you are good to go.

If you have different router the experience and visualisation may differ, but the principle is the same. You just have to open port 443 in your router and forward it to your local Home Assistant IP on port 8123.

You also have to assign a static IP address for the server where your Home Assistant is installed. If you don’t know how to do that just ask in the comments section below or search in Google.

Creating a DuckDNS sub domain

Now you have to create a DuckDNS sub domain. This will be the address that you will enter in the browser the Home Assistant remote access.

Just go to DuckDNS.org and login with either of the available options (Persona, Twitter, GitHub, Reddit, Google) and then create a new sub domain. In a similar way as in the picture below.

Home Assistant Remote Access with DuckDNS and Let’s Encrypt - Kiril Peyanski's Blog (2)

Then copy the DuckDNS token above your newly created sub-domain and head over to your Home Assistant with a smile.

Adding DuckDNS add-on in Home Assistant

Open your Home Assistant and press, the “c” button to invoke the search bar, type add-on and choose Navigate Add-On store.

Or just click the My Home Assistant Link below:

Home Assistant Remote Access with DuckDNS and Let’s Encrypt - Kiril Peyanski's Blog (3)

Search for DuckDNS add-on and install it.

Go to the configuration tab of DuckDNS add-on and:

  1. Change the accept_terms to true. By changing it, you agree to use Let’s Encrypt auto renewal SSL certificate feature. And that is really good.
  2. Add your DuckDNS token next to the token: keyword.
  3. Add your DuckDNS subdomain (get it from the duckdns.org website) under domains:
Home Assistant Remote Access with DuckDNS and Let’s Encrypt - Kiril Peyanski's Blog (4)

Save the changes and start the add-on. You should see no errors in the logs and if that is the case you are just perfect.

Set Home Assistant internal and external URLs

Now is the right time to set up your internal and external URLs for our Home Assistant remote access.

You have to edit your Home Assistant configurations

Editing configuration.yaml file

Open the configuration.yaml file with your favourite editor and paste inside the following lines under your homeassistant: section:

# configuration.yaml entry homeassistant: external_url: https://YOUR_SUBDOMAIN_HERE.duckdns.org internal_url: http://YOUR_INTERNAL_HA_IP_HERE:8123

Don’t forget to replace YOUR_SUBDOMAIN_HERE & YOUR_INTERNAL_HA_IP_HERE with yours.

You can save the file, but don’t close it yet! We will need it a bit more in the next section.

Home Assistant http section

To enable a secure Home Assistant Remote Access we have to tell the Home Assistant where to find the SSL certificate and key from Let’s Encrypt.

It is not hard just paste the following lines in your configuration.yaml file:

# configuration.yaml entry http: ssl_certificate: /ssl/fullchain.pem ssl_key: /ssl/privkey.pem ip_ban_enabled: true login_attempts_threshold: 5

Double check that you don’t have http: section already in your file. If so, copy only the last 4 lines from the above in your configuration.yaml file

The last two lines from above YAML are helping to harden the security. If you enable IP Ban option with threshold 5 as in the example, and if someone tries to login 5 times with a wrong password in your Home Assistant – it will be banned automatically.

After the first ban, anip_bans.yamlfile will be created in the root configuration folder. It will have the banned IP address and time in UTC when it was banned. So you can rest assured that you have a secure Home Assistant remote access.

Save the changes, check your configuration and restart your Home Assistant server.

After the restart you can check if your Home Assistant remote is working and you can access it remotely for the first time.

Just open the https://YOUR_SUBDOMAIN_HERE.duckdns.org in a new browser or tab.

Congratulations! You deserve it! Really!

But, don’t stop reading now. You have just few more step to make this whole setup even more secure!

What if Home Assistant Remote Access is not working or you loose your local access?

After the above implementation you may face difficulties accessing your local or remote Home Assistant address. First of all, don’t panic! Second, double check these things:

  1. Make sure that you type https:// and not http:// before your local & external address of your Home Assistant,
  2. Make sure that you are not banned by the ip_ban_enabled option. That means your IP is not in the ip_bans.yaml file. If it is there just delete it and/or disable the ip ban option by set ip_ban_enabled: false in configuration.yaml file
  3. Clear your browser cache or open an private/incognito window and try again. You can also try with different browser.
  4. Don’t expect to have Trusted SSL certificate when access your local address. That is not possible! That means – you will receive warnings from your browser when you access the https version of your local Home Assistant. Depending of the browser that you are using you may add your local Home Assistant https address as exclusion once and you will not receive any warnings after that.
  5. The Trusted SSL certificate by remote authority like Let’s Encrypt is only possible with your external IP (duckDNS subdomain or other domain).
  6. Correct port forwarding in your router is crucial for this Home Assistant remote access to work – Double, not Triple check it and test it.
  7. If you didn’t install and start the DuckDNS add-on. You will receive errors that ssl files and folders are missing when trying to check your Home Assistant configuration or during the Home Assistant start.

Two other ways for Home Assistant remote access

There are also few other ways for Home Assistant remote access.

  1. Free Cloudflare Tunnel To Home Assistant: Full Tutorial!
  2. You can use a VPN. I will recommend to invest some of your time into configuring and setup a VPN to securely access everything in your home and to leave your ports closed. These are my VPN tutorials that you could use.
    • WireGuard VPN from Home Assistant Easy Setup – link
    • Raspberry Pi into VPN (How-To) with ZeroTier – link
  3. You can also use the Home Assistant Cloud service called Nabu Casa. This a secure and easy way, but it will cost you 6 dollars monthly to have it. You can try the service for free for 30 days.

Quick question for You

Nobody answers my questions in the articles for unknown reason to me.

Would you like to brake that rule?

If yes, then let me know in the comments which Home Assistant Remote Access is better for you?

  1. Using a VPN,
  2. Using the Cloud Service,
  3. Using this method that I’m showing.

Regardless of what you choose just be sure that you smashed the subscribe button for my Newsletter.

One more thing…

And before we harden the Home Assistant remote access, there is one more thing that I want to share with you.

Yes, exactly you who read this article till this very moment!

I have a Home Assistant Webinar on which I’m talking about 4 different official ways to install Home Assistant + 1 secret stupid easy way. This webinar is completely free of charge and you can watch it instantly by register on this link 👉 https://automatelike.pro/webinar

I hope you will like it as much as I do. Now let’s continue!

Harden the Home Assistant Remote Access Security more

Log in your Home Assistant and click on your username in the lower left corner of the screen.

Then do the following:

  1. Change your password with a password that contains: letters in upper and lower case, digits and special characters. It will be best if you use this password only for your Home Assistant and nowhere else.
  2. Enable Multi-factor Authentication Modules – I’m using Google Authenticator for that.
    • Download it for free from you your mobile phone store.
    • Open it and scan the code that Home Assistant will display with the authenticator app.
    • Then the authenticator will display a code that you will have to enter in Home Assistant.
    • From now on every-time you want to log in Home Assistant from new device, you will have to enter your username, password and a generated code in the Google authenticator that is changed every 30 secs.
Home Assistant Remote Access with DuckDNS and Let’s Encrypt - Kiril Peyanski's Blog (5)

Activating ip_ban_option and Multi-factor Authentication Modules is a must if you enable your Home Assistant Remote Access in the way that i’m showing with the port forwarding and SSL. So don’t skip this!

Support my work

If you like the Home Assistant Remote Access with DuckDNS and Let’s Encript Article and you want more content like this you may want to become one of my supporters. Check exactly how onmy support page!

Any other sort of engagement on this site and myYouTube channeldoes really help out a lot with the Google & YouTube algorithms, so make sure you hit thesubscribe, as well as theLike and Bellbuttons.

Also feel free to add me onTwitter by searching for @KPeyanski. You canfind me on my Discordserver as well.

I really hope that you find this information useful and you now know how to setup Home Assistant remote access with DuckDNS and Let’s Encrypt and of course some port forwarding

Stay safe and don’t forget – Home Smart, But Not Hard!

Thank you for reading, I will see you in the next article.

Home Assistant Remote Access with DuckDNS and Let’s Encrypt - Kiril Peyanski's Blog (2024)

FAQs

How do I securely access Home Assistant remotely? ›

If you want secure remote access, the easiest option is to use Home Assistant cloud by which you also support the founders of Home Assistant. Another option is to use TLS/SSL via the add-on Duck DNS integrating Let's Encrypt. To expose your instance to the internet, use a VPN, or an SSH tunnel.

How do I add duck DNS to Home Assistant? ›

Install and configure the DuckDNS add-on in Home Assistant by following these steps:
  1. Open Home Assistant and go to Settings > Add-ons.
  2. Click the Add-On Store button and search for the DuckDNS add-on.
  3. Select the DuckDNS add-on from the search results and then click the Install button.
Oct 25, 2022

How do I set up Letsencrypt Home Assistant? ›

Install the Let's Encrypt Addon

Log into your Home Assistant web portal and then go to “Settings” > “Add-ons”. Click on the “Add-on Store” on the bottom right corner and search for “Let's Encrypt”. Click “Install” but do NOT select “Start on Boot”. We'll enable this at the very end.

Is it safe to use DuckDNS? ›

Malicious behavior

The domain duckdns.org hosts a free service which will point a DNS (sub domains of duckdns.org) to an IP of your choice. Unfortunately this service is often abused by phishers.

Can remote access be monitored? ›

Remote Access monitoring reports remote user activity and status for DirectAccess and VPN connections. It tracks the number and duration of client connections (among other statistics), and monitors the operations status of the server.

Which method of remote access is the most secure? ›

Virtual private network (VPN):

VPNs are the most common form of remote access. They use authentication and encryption to establish a secure connection to a private network over the internet.

What is let's encrypt for Duck DNS? ›

Let's Encrypt for Duck DNS

Automatically generates Let's Encrypt certificates using a lightweight Docker container without requiring any ports to be exposed for DNS challenges.

What is the remote URL for Home Assistant? ›

If you use Home Assistant OS and haven't changed any of the defaults, Home Assistant will also be reachable at http://homeassistant.local:8123.

How do I access Home Assistant from outside the Network? ›

You can use any free port on your router and forward that to port 8123. A problem with making a port accessible is that some Internet Service Providers only offer dynamic IPs. This can cause you to lose access to Home Assistant while away. You can solve this by using a free Dynamic DNS service like DuckDNS.

How do I get Let's Encrypt certificate manually? ›

Do the following to obtain the certificate: 1. sudo certbot certonly --manual -d DOMAIN NAME - e.g. sudo certbot certonly --manual -d affairs.ccu.edu.tw 2. Choose the Webroot plugin 3. Fill in your email, so that when the certificate is almost expired they will send a notification to you.

How do I enable Letsencrypt? ›

Enabling Let's Encrypt

Select the site and then go to Site Dashboard. Scroll down and then select the SSL tab in the portal. The SSL certificate status will show as installed if the Let's Encrypt certificate has been installed for the site when your site went live.

How do I access Home Assistant configuration? ›

If you use Home Assistant Container, you can find configuration.yaml in the config folder that you mounted in your container. If you use Home Assistant Operating System, you can find configuration.yaml in the /config folder of the installation.

Is it safe to expose Home Assistant to internet? ›

Absolutely NEVER EVER EVER expose a bare unsecured SSL HAport:8123 to the open internet without security or you'll be owned faster you can unplug the cat 5 cable.

Is there a free alternative to DuckDNS? ›

The 6 Best Free Dynamic DNS Providers
  • Dynu.
  • afraid.org.
  • DuckDNS.
  • No-IP.
  • ClouDNS.
  • Dynv6.
Jun 12, 2023

Is DNS safer than VPN? ›

Our Verdict. Smart DNS and VPN services both unblock geo-restricted websites and stream video content from abroad. However, only a VPN hides your IP address and encrypts your web traffic. Custom DNS doesn't spoof your location or encrypt your data transfers, but it can improve your internet speeds and security.

How do I secure my remote work device? ›

REMOTE SECURITY BEST PRACTICES FOR EMPLOYERS
  1. Migrate your business applications to the cloud. ...
  2. Require employees to connect over VPNs. ...
  3. Install multi-factor authentication. ...
  4. Implement BYOD/MDM policies. ...
  5. Use password managers. ...
  6. Train employees on best practices.

What is the best VPN for Home Assistant? ›

Tailscale is a preferred VPN service to access the Home Assistant server due to many reasons, such as:
  • It's built on top of Wireguard. Thus, it offers security and performance similar to Wireguard.
  • It's much easier to set up and use than Wireguard.
  • It offers excellent bandwidth and network latency.
Mar 24, 2023

How do I log into Home Assistant without password? ›

Sign in as “root”. There is no password. You will then be at the Home Assistant CLI, where you can run the custom commands.

Top Articles
Latest Posts
Article information

Author: Jonah Leffler

Last Updated:

Views: 6304

Rating: 4.4 / 5 (65 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Jonah Leffler

Birthday: 1997-10-27

Address: 8987 Kieth Ports, Luettgenland, CT 54657-9808

Phone: +2611128251586

Job: Mining Supervisor

Hobby: Worldbuilding, Electronics, Amateur radio, Skiing, Cycling, Jogging, Taxidermy

Introduction: My name is Jonah Leffler, I am a determined, faithful, outstanding, inexpensive, cheerful, determined, smiling person who loves writing and wants to share my knowledge and understanding with you.