ESPHome API error: "Invalid preamble" from <ip>

Problem:

  • Using the ESPHome Web Server API I’m getting the following errors making the following POST requests via Postman to trigger a toggle on my device (also see attached images):

"Error: socket hang up" (when specifying port 6053)
"Invalid preamble from " - this is from the ESPHome log

Requests:

Note: I assume port 6053 is needed because without it (i.e. default port 80) not only do I get a Error: connect ECONNREFUSED error but the ESPHome log doesn’t log the request

Notes:

  • garage-door-left and garage-door-left.local come from the ESPHome log (see attached image)
  • Triggering the entity (switch.left_garage_switch) in Home Assistant works as expected


It operates on port 80 and it needs the web server set up with

web_server:
  port: 80

Do you have that set up?

Thanks @nickrout, I hadn’t, but just now I added it to my /config/esphome/garage-door-left.yaml, then restarted ESPHome but it didn’t change the behavior I described. I see the documentation for Web Server API states:

  • First up, to use the web server enable it using App.init_web_server() directly from code or using the Web Server Section in ESPHome. Then, navigate to the front end interface with the IP of the node or alternatively using mDNS with <name>.local/

I’m not sure how “…using the Web Server Section in ESPHome” enables the web server but I did try navigating to the following but it didn’t resolve:

I’m sure I’m probably just missing something obvious…

image

navigate to the ip address.

After adding the web server section you did recompile and upload right? Not restart the addon

Thank guys! Adding web_server: port:80 to my garage-door-left.yaml (@nickrout) followed by doing an Upload from ESPHome (@samnewman86) enabled the POST to work as expected. I’m sure you guys can tell, I’m a bit of a ESPHome newbie (this was my first experience), I usually use Tasmota.

  • I’ll be looking for an iPhone solution to make a POST request so I can give this to my kids (w/out the need for HA), I can successfully use Tasker to make the POST on Android

Thanks again for your help!

As I have some attention here I was wondering if anyone might have any thoughts regarding my daylight savings time question/post?

image

Perhaps you have heard of search engines. Searchin ‘iphone post’ in this thing called google found this

@nickrout, I’m not sure if that last comment was a legit joke or just a really obnoxious and uncalled for snide remark?

In case of the latter, I did not reach out for help in making a POST request from an iPhone, I simply stated:

  • I’ll be looking for an iPhone solution to make a POST request so I can give this to my kids (w/out the need for HA)

The purpose of the comment was simply for those who might be interested in additional context as to how I’m going to leverage what I’ve learned from this forum/post thanks to those such as yourself and @samnewman86 who were kind enough to take time out of their own day to answer questions in this forum to help others like me.

I do apologize if that statement came across as some pathetic plea for someone else to do a google search for me, I can assure you that wasn’t the intent lol! :slight_smile:

Perhaps it was a little early in the morning, sorry about that.

No problem, all good :slight_smile: