Espota from internet

Good morning,
I have an ESP32 that works 24h/24, which I can update with vscode remotely (OTA) from the local network.
On the same home LAN I have a NAS with reverse proxy. So from the internet, a:


reaches the NAS

My question: is it possible to reprogram the ESP32 from the internet?

Now I put in the

upload_port =;
upload_flags =
upload_protocol = espota

but I get this:

21:46:46 [DEBUG]: Options: {'esp_ip': '', 'host_ip': '', 'esp_port': 3232, 'host_port': 58404, 'auth': 'password', 'image': '.pio\\build\\esp-32\\firm ware.bin', 'spiffs':
False, 'debug': True, 'progress': True, 'timeout': 10}
21:46:46 [INFO]: Starting on
21:46:46 [INFO]: Upload size: 821168
Sending invitation to ..........
21:48:26 [ERROR]: No response from the ESP
*** [upload] Error 1

Is it just possible?
Thank you

Where’s a weird space here for no reason? Did you modify env["PROGNAME"]?

The ESP32 should not care where the conenctions come from. If UDP port 3232 is port-forwarded to the ESP on that domain, it should work.

Sorry I don’t understand the first point. I did not enter this instruction anywhere.

And no, I did not modify the env[“PROGNAME”] paragraph in the platformio.ini file.

I don’t know if Synology’s reverse proxy sends messages in UDP because I have configured it as follows :

Besides, I haven’t opened any particular ports on my internet box. I thought it was not useful because I am accessing all machines on my local network correctly.

But neither the destination not source protocol is HTTP. And if you configured the SRC to be on port 80, then you would also need to tell PlatformIO to access that port from the outside. Do you have the option to setup a 1:1 relationship between Source UDP 3232 and Destination UDP 3232? That should make it work without modifications.

No i can’t do that in my reverse proxy but it’s possible using NAT with my internet box.
I will try
Thank you for this idea

I just changed the settings of my internet box to transfer everything that comes in UDP port 3232 to my esp with the same port 3232.
Obviously it’s a little bit better

Here is the result :

Successfully created esp32 image.
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = espota
Uploading .pio\build\esp-32\firmware.bin
22:18:28 [DEBUG]: Options: {'esp_ip': '', 'host_ip': '', 'esp_port': 3232, 'host_port': 23524, 'auth': 'password', 'image': '.pio\\build\\esp-32\\firmware.bin', 'spiffs': 
False, 'debug': True, 'progress': True, 'timeout': 10}
22:18:28 [INFO]: Starting on
22:18:28 [INFO]: Upload size: 821168
Sending invitation to 
Authenticating...OK       <---- NEW
22:18:28 [INFO]: Waiting for device...
22:18:38 [ERROR]: No response from device
*** [upload] Error 1

No change in platformio.ini and I confirm there is no space in the word “firmware”.

Oh, actually this process is more complicated. It starts off with UDP, but then it will ask the ESP to connect to the given TCP server port opened by the computer, i.e., from the ESP32 (source port probably random) to the computer, target port 23524 in this case. See source code. This port number is however random

So what you should do:

  1. Use upload_flags in the platformio.ini to add --host_port, then it should have a fixed TCP server port on the PC side
  2. Make another rule so that the ESP32 can reach your computer’s TCP server port as decided above

First, thank you Maxgerhardt for your help !
Then, I’ve fixed host_port in platformio.ini

upload_port =  ; it's the IP adress of my internet box
upload_flags = 
	--host_port=22564 ; selected by me
upload_protocol = espota

then, the rules are now

  • protocole=tous means protocole=tcp or udp
  • is the local IP adress of the ESP
09:28:48 [DEBUG]: Options: {'esp_ip': '', 'host_ip': '', 'esp_port': 3232, 'host_port': 22564, 'auth': 'password', 'image': '.pio\\build\\esp-32\\firmware.bin', 'spiffs': False, 'debug': True, 'progress': True, 'timeout': 10}
09:28:48 [INFO]: Starting on
09:28:48 [INFO]: Upload size: 821168
Sending invitation to 
09:28:48 [INFO]: Waiting for device...
09:28:58 [ERROR]: No response from device
*** [upload] Error 1

a problem remains …

To complete, if I deactivate the firewall of my internet box and the firewall of my computer, the problem persists.

Then something is still wrong with the port forwarding. I guess you could a very minimal sketch for the ESP32 (uploaded via serial) that tries to connect to TCP 22564 on your computer’s IP address (e.g. derived from this) while a minimal TCP server is opened by e.g. this program.

Thank you Maxgerhardt, I continue to search.