ERROR (MainThread) [aiohttp.server] Error handling request

I have this error:

2021-11-17 13:19:05 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 314, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"

And no duckdns.

Have you reinstalled home assistant at one point or another? This is what helped me:

Update: No not the same config. After another check of the shellscript I noticed a difference in the volume-mapping and the path didn’t exist, causing probably the mentioned errormessage.

I’m seeing this when updating my Docker container with the latest stable version. If I update it with the latest version (getting a dev-version of HA) then it works fine. Same config.

Hello,

I have very similar problem. Is there any progress with this issue?
my log:

2022-02-22 23:12:26 ERROR (MainThread) [aiohttp.server] 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'"

Same issue here too.

Using HASSOS VM on Synology and reverse proxy:

Here’s my HTTP YAML config:

http:
    use_x_forwarded_for: true
    trusted_proxies: 192.168.2.2
    cors_allowed_origins:
        - https://hass.example.com
        - https://192.168.2.2
Logger: aiohttp.server
Source: /usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py:405
First occurred: 4:22:59 PM (1007 occurrences)
Last logged: 4:25:41 PM

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'"

System Health

version core-2022.4.0
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.9.9
os_name Linux
os_version 5.10.108
arch x86_64
timezone America/Los_Angeles
Home Assistant Cloud
logged_in true
subscription_expiration April 25, 2022, 5:00 PM
relayer_connected true
remote_enabled false
remote_connected false
alexa_enabled false
google_enabled true
remote_server us-west-2-1.ui.nabu.casa
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 7.6
update_channel stable
supervisor_version supervisor-2022.03.5
docker_version 20.10.9
disk_total 59.3 GB
disk_used 11.1 GB
healthy true
supported true
board ova
supervisor_api ok
version_api ok
installed_addons Z-Wave JS (0.1.55), File editor (5.3.3), MariaDB (2.4.0), Grafana (7.5.2), InfluxDB (4.4.1)
Dashboards
dashboards 2
resources 0
views 2
mode storage

Hmm, same here. Seems to happen when I try to do a backup snapshot. Using HTTP, not HTTPS (only local network access) so HTTP: is empty in my config
Running HASSIO on a pi4

Anyone with a clue?

22-11-02 00:53:42 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/aiohttp.py", line 122, in sentry_app_handle
    reraise(*_capture_exception(hub))
  File "/usr/local/lib/python3.10/site-packages/sentry_sdk/_compat.py", line 56, in reraise
    raise value
  File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/aiohttp.py", line 112, in sentry_app_handle
    response = await old_handle(self, request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/supervisor/supervisor/api/middleware/security.py", line 138, in system_validation
    return await handler(request)
  File "/usr/src/supervisor/supervisor/api/middleware/security.py", line 156, in token_validation
    return await handler(request)
  File "/usr/src/supervisor/supervisor/api/proxy.py", line 169, in websocket
    await server.prepare(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_ws.py", line 137, in prepare
    protocol, writer = self._pre_start(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_ws.py", line 239, in _pre_start
    assert transport is not None
AssertionError

I’m seeing this after updating to the latest release of HA. Adding base_url to my config didn’t help :frowning:

Thank you for the tip!
Had the same issue, after a couple of tries, I found out that I had linked my Netatmo to HASS.
Just logged in onto Netatmo account and deleted the linkage - and now it works!

1 Like

My issue was Node Red trying to connect to HA with HTTPS, while HA was configured for HTTP. See my Post: Finding the source of an aiohttp.server 400 message - #14 by pixeldoc2000

If HA is configured for HTTP, make sure everything is connecting to HA via HTTP (like Revers Proxy, Node Red, Scripts, Services, etc.)

I fought this error for a few weeks/months too…

Removed DuckDNS, reinstalled… Still exists…
Added NGINX still exists.
Replaced SQL Lite DB with Maria DB… Still exists…
Added all config http: changes noted above… still exists.
Removed all apples devices… still exists.
Checked fire wall port forward rules (reboot router over and over and over) still exists.
Improved cooling solutions and new Pi power adapter… Still exists.

The only clue was these errors were being generated randomly throughout the day (and night)… when people were home and when they were away. The system did seem to get lots of them around sunrise and sunset. Often to a point of causing the system to crash.

Then I noticed that the web-hooks that MotionEye automatically generate contained a malformed IP address… I don’t use those web-hooks so I turned them off and set the MotionEye Integration configuration to NOT automatically created web hooks and

Ta Da… no more “aiohttp.server Error” at least for 48 hrs… which is a record.

I will know in a week or so… But I suspect when all of my security cameras would switch from “day mode” to IR dark mode. MotionEye would spam HA with a bunch of malformed web-hooks.

But that is a guess.