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

hi all - i fixed this by adding the full address of the site into the http: component under base_url
I believe the error comes is caused in most instances by using https without having this set in the configuration.yaml

http:
  base_url: https://hass.example.com
2 Likes

I’ve always had it in that format so don’t think it’s the issue…

THANK YOU FOR THIS!
I was bashing my head against the wall. A FRIKKIN SPACE!!! Deleted it, solved.

1 Like

If you use VSCode look into the ‘YAML’ linter which will highlight YAML errors in your configs. :slight_smile:

1 Like

This did it for me also. Running Home Assistant in docker.

Thanks!

hello, i am having the same issue on a fresh synology vmm installation, from hassos_ova-5.9.vmdk & hassos_ova-5.8.vmdk images.

2020-12-21 10:06:57 ERROR (MainThread) [frontend.js.latest.202012120] chrome-extension://mooikfkahbdckldjjndioackbalphokd/assets/prompt.js:1:1 Uncaught SyntaxError: Identifier ‘originalPrompt’ has already been declared

2020-12-21 10:10:03 ERROR (MainThread) [frontend.js.latest.202012120] chrome-extension://mooikfkahbdckldjjndioackbalphokd/assets/prompt.js:1:1 Uncaught SyntaxError: Identifier ‘originalPrompt’ has already been declared

2020-12-21 10:28:19 ERROR (MainThread) [aiohttp.server] Error handling request

Traceback (most recent call last):

File “/usr/local/lib/python3.8/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’”

2020-12-21 10:28:19 ERROR (MainThread) [aiohttp.server] Error handling request

Traceback (most recent call last):

File “/usr/local/lib/python3.8/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’”

2020-12-21 10:28:19 ERROR (MainThread) [aiohttp.server] Error handling request

Traceback (most recent call last):

File “/usr/local/lib/python3.8/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’”

2020-12-21 10:28:19 ERROR (MainThread) [aiohttp.server] Error handling request

Traceback (most recent call last):

File “/usr/local/lib/python3.8/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’”

2020-12-21 10:28:26 ERROR (MainThread) [frontend.js.latest.202012120] chrome-extension://mooikfkahbdckldjjndioackbalphokd/assets/prompt.js:1:1 Uncaught SyntaxError: Identifier ‘originalPrompt’ has already been declared

2020-12-21 10:29:36 ERROR (MainThread) [frontend.js.latest.202012120] chrome-extension://mooikfkahbdckldjjndioackbalphokd/assets/prompt.js:1:1 Uncaught SyntaxError: Identifier ‘originalPrompt’ has already been declared

i understand it is because of url https, but how can i fix it ???

no more solution in aiohttp.server Error handling request · Issue #17387 · home-assistant/core · GitHub

tks in advance.
Arnaud

I have the same error: It has to do something with my Denon Speakers “saying” an .MP3 alarm message.

I use this syntax in my Node-red automation. What is wrong with the Syntax??
I tried without adding the port number :8123. And I tried with https://
I get always the same error. See below
PS: The message is played correctly on my Denon Heas

Syntax in Node-red is:
{
“media_content_type”: “url”,
“media_content_id”: “http://192.168.0.130:8123/local/beweging_gedetecteerd_man.mp3
}

Error message received:
2021-01-21 14:04:45 DEBUG (MainThread) [pyheos.connection] Event received for player {Heos Bureau (HEOS 3)}: {‘command’: ‘event/player_playback_error’, ‘message’: ‘pid=2021190917&error=Unable to play media. Please try again later.’}

2021-01-21 14:04:45 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):

File “/usr/local/lib/python3.8/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’"

yeah, same for me!
thanks!

Same issue here

Logger: aiohttp.server
Source: /usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py:393
First occurred: 22:44:45 (4 occurrences)
Last logged: 22:47:20

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’”

I am also experiencing this same issue and no one seems to want to help. Its a pretty generic error message so its hard for me to debug. What I read from another thread is that someone is pinging the server because we’re using duckDNS. Are you guys all using duckDNS?

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.