ESP8266 located in any network

Is it possible to connect esp8266 located in any network (connected to internet) to home assistant? Please, help with example or direction to go.

Nope it’s specifically designed to be used only on LAN and LAN communications. ESP is not designed to be connected at Internet straight !

I think this might be possible, see links below:

You probably need to open ports in the firewall of your router, but it should be possible.
ESPHome runs a full TCP/IP stack, so no block there.
Auto discovery might not work, but manually putting in the IP when setting up the integration should be good enough.

Best to use a vpn.

I so agree with nickrout!
ESP devices usually have very limited resources, both in CPU, RAM and storage, so shortcuts have to made here and there. The device might never be hardened enough for open internet access.

Also remember that esphome is the server for API comms, so the connection is made from home assistant to the esp. This means that it is at the esp end that you’d have to punch a hole in a firewall on port 6053.

I have ESPhome devices running on a 4g router with a vpn to the main site. Essentially same network but different subnets.

Why does everyone want to make it hard? Use MQTT and connect your nodes and Home Assistant to a public broker.


At some stage you will expose something to the baddies, whether by using a public broker, or opening a vpn.


The fear of IOT as a vector for bad operators is way overblown. Can anyone point to a verified report of this ever happening? I don’t mean a kiddie prank where a hacker set your heat to 98°F, but any verified network penetration.

But this got me to thinking- because I do have a need for WAN access to my broker. What if I were to put my MQTT broker on DuckDuckGo?

I agree. How is MQTT over SSL/TLS any worse than a browser using https?

The main problem would be with bad actors gaining access to your data on the network you don’t control, in the broker space.

Easier than deploying a MQTT server in the WWW might be just to call a webhook via nabucasa from the remote esphome node.

Various topics and snippets about this exist in the forum here.

Ether way (MQTT or webhook) the esphome node is able to communicate with HA but all the lovely management features will not be available that way.

Using a site-2-site VPN (like wireguard or tailscale which can directly run on routers) will give full control and allow use of the native api and all other goodies.

1 Like

Do you have a step by step on how to do it…

  1. I have hassio on pi
  2. I have a domain linked through cloudflare that I can I access from anywhere

House 1 has esp with esphome (no hassio)
House 2 has the above 1 & 2

How do I setup mqtt to have house 1 visible on house 2 hassio.

I can re setup the esphome on the esp32 In house 1 when needed.

It’s hard to find a step by step… including .yaml configuration

I don’t want to use VPN.
Other methods are welcome


  1. Use MQTT on a public broker.

I have no clue what Cloudfare is, and I have never used ESPHome without Home Assistant. More, Your description is remarkably vague. What does the ESP in house 1 do and how do you communicate with it now?


Home 1 has sensors setup with a piezo buzzer as a trigger. I cannot monitor anything at home 1 at the moment. Therefore looking for a solution

I’m only using esphome. I’m not to clued up on MQTT.

Let me know if this is correct:

  1. Install broker on HA
  2. Configure home 1 esphome .yaml to include MQTT details.

Set up an account on a public broker

point the esphome device to it

Use your local mqtt broker on HA to connect to the public one.

How is a buzzer a trigger??

As I said, I’ve never used ESPHome without Home Assistant, but I can’t imagine it would be much different.

Looks like it is now even possible to ‘just’ install (and configure) the wireguard add on in HA and then use wireguard directly on a remote esphome (esp32) node like described in the docs :point_down:

Wireguard is a great idea, but

Thanks for the tip, I had missed the addition of wg.