core: aiohttp.server message="Bad status line 'Invalid method encountered'"

The problem

After upgrade to newest 2022.6.7 i see this error at logs

What version of Home Assistant Core has the issue?

2022.6.7

What was the last working version of Home Assistant Core?

i dont remember

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: aiohttp.server
Source: /usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py:405
First occurred: 03:36:42 (3 occurrences)
Last logged: 08:20:30

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 334, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 551, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'Invalid method encountered'"

Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 10
  • Comments: 65 (2 by maintainers)

Most upvoted comments

Same issue here, any updates on this?

I have a feeling it relates back to Nginx, which I’m using to reverse-proxy to my HA instance. I don’t have any issues (I don’t think) from the app on iOS, but when using Firefox on my laptop it can take ages to load HA through the reverse proxy and I see the same errors others are reporting…

Not an issue in my case.

After searching on the internet I came to conclusion that one of my devices in LAN is trying to connect to :8123 port using HTTPS.

I’ve reviewed all phones and tablets and turned out it was my sons device.

This was coincidence that it happened after upgrade.

With regards to the first error, it’s possible that your webserver is mistakenly trying to speak unencrypted HTTP to a request that came in on port 443 (HTTPS).

Source

If you have a Home Assistant instance that doesn’t integrate the SSL certificate in the main configuration and you (or an integration, plugin, etc.) are trying to access the encrypted version of the API / dashboard, this error is going to appear.

Check the http configuration.

http:
  server_port: 8123
  ssl_certificate: /etc/letsencrypt/live/YOUR_DDNS_URL.com/fullchain.pem
  ssl_key: /etc/letsencrypt/live/YOUR_DDNS_URL.com/privkey.pem
  cors_allowed_origins:
    - https://google.com
    - https://www.home-assistant.io
    - https://cast.home-assistant.io
    - cast.home-assistant.io
    - https://YOUR_DDNS_URL.com:8123

I use Home Assistant like this without trouble, over TLS / SSL.

Still active issue.

I found out that such errors occur when the https://about.censys.io/ service sends requests like: 167.94.138.126 [28/Apr/2023:01:49:57 +0000] “GET / HTTP/1.1” 404 172 “-” “Mozilla/5.0 (compatible; CensysInspect/1.1; +https://about.censys. io/)” On their official website, you can see from which ip addresses this happens and block them on the server->> https://support.censys.io/hc/en-us/articles/360043177092-Opt-Out-of-Data-Collection

Double-check the URL you’re using in your request. Make sure it’s correctly formatted and that there are no extra characters or spaces. Ensure the URL scheme (http/https) is correct for the API you’re using. I had a similar problem, I specified the port to a URL, but it was not necessary.