home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.49k stars 30.33k forks source link

Error with socket X (('<IPV6 address>', 5353, 0, 2))): [Errno 1] Operation not permitted (Zeroconf) #87489

Closed simphide closed 1 year ago

simphide commented 1 year ago

The problem

I am currently getting the following error from Zeroconf as soon as Home Assistant starts:

2023-02-05 19:36:33.089 WARNING (MainThread) [zeroconf] Error with socket 16 (('fe80::921b:eff:fe5b:79f3', 5353, 0, 2))): [Errno 1] Operation not permitted
Traceback (most recent call last):
File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 1054, in sendto
self._sock.sendto(data, addr)
PermissionError: [Errno 1] Operation not permitted

This is then follower by these recurring error messages:

2023-02-05 19:36:33.094 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=20 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=20, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 41348, 0, 0)>
2023-02-05 19:36:33.802 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>

When I grep via netstats for the ports that Home Assistant is using, I get the following:

simon@homeserver:~$ sudo netstat -tulpn | grep 1101430/python3
tcp        0      0 192.168.178.31:40000    0.0.0.0:*               LISTEN      1101430/python3
tcp        0      0 0.0.0.0:8123            0.0.0.0:*               LISTEN      1101430/python3
tcp6       0      0 fe80::921b:eff:fe:40000 :::*                    LISTEN      1101430/python3
tcp6       0      0 :::8123                 :::*                    LISTEN      1101430/python3
udp        0      0 0.0.0.0:48886           0.0.0.0:*                           1101430/python3
udp        0      0 192.168.178.31:5353     0.0.0.0:*                           1101430/python3
udp        0      0 0.0.0.0:46837           0.0.0.0:*                           1101430/python3
udp        0      0 0.0.0.0:1900            0.0.0.0:*                           1101430/python3
udp        0      0 0.0.0.0:1900            0.0.0.0:*                           1101430/python3
udp        0      0 0.0.0.0:60474           0.0.0.0:*                           1101430/python3
udp6       0      0 :::41348                :::*                                1101430/python3
udp6       0      0 :::33651                :::*                                1101430/python3
udp6       0      0 :::5353                 :::*                                1101430/python3
udp6       0      0 fe80::921b:eff:fe5:5353 :::*                                1101430/python3
udp6       0      0 :::1900                 :::*                                1101430/python3
udp6       0      0 :::1900                 :::*                                1101430/python3

The network adapter shows that the IPv6 address is correct: image

Does it lead to trouble that Home Assistant trys to use Port 5353 via :::5353 and fe80::921b:eff:fe5:5353?

Best regards Simon

What version of Home Assistant Core has the issue?

Home Assistant 2023.2.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Zeroconf

Link to integration documentation on our website

https://www.home-assistant.io/integrations/zeroconf/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-02-05 19:36:33.089 WARNING (MainThread) [zeroconf] Error with socket 16 (('fe80::921b:eff:fe5b:79f3', 5353, 0, 2))): [Errno 1] Operation not permitted
Traceback (most recent call last):
File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 1054, in sendto
self._sock.sendto(data, addr)
PermissionError: [Errno 1] Operation not permitted
2023-02-05 19:36:33.094 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=20 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=20, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 41348, 0, 0)>
2023-02-05 19:36:33.802 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:37:03.806 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:37:33.809 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:38:03.811 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:38:33.095 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=20 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=20, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 41348, 0, 0)>
2023-02-05 19:38:33.815 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:39:03.817 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:39:33.820 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:40:03.822 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:40:33.096 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=20 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=20, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 41348, 0, 0)>
2023-02-05 19:40:33.825 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:41:03.827 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:41:33.829 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:42:03.832 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:42:33.097 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=20 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=20, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 41348, 0, 0)>
2023-02-05 19:42:33.835 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:43:03.838 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:43:33.841 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:44:03.844 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:44:33.098 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=20 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=20, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 41348, 0, 0)>
2023-02-05 19:44:33.847 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:45:03.850 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:45:33.853 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:46:03.856 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:46:33.099 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=20 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=20, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 41348, 0, 0)>
2023-02-05 19:46:33.859 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:47:03.862 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:47:33.865 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:48:03.868 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:48:33.100 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=20 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=20, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 41348, 0, 0)>
2023-02-05 19:48:33.871 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:49:03.873 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>
2023-02-05 19:49:33.877 ERROR (MainThread) [async_upnp_client.ssdp] Received error: [Errno 1] Operation not permitted, transport: <_SelectorDatagramTransport fd=27 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::', 33651, 0, 0)>

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (zeroconf) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `zeroconf` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign zeroconf` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


zeroconf documentation zeroconf source (message by IssueLinks)

simphide commented 1 year ago

The problem still persists 😐

Masterz69 commented 1 year ago

While IPv6 is disabled in HA configuration: image

See it anyway enabled/exists on HA OS/Supervisor (?) level: image

That leading to following: mDNS occasionally returns IPv6 addresses.

➜  ~ wget http://ewelink_100169f2ad.local.:8081/zeroconf/info
--2023-02-18 20:37:08--  http://ewelink_100169f2ad.local.:8081/zeroconf/info
Resolving ewelink_100169f2ad.local. (ewelink_100169f2ad.local.)... fe80::96b5:55ff:fef7:f108
Connecting to ewelink_100169f2ad.local. (ewelink_100169f2ad.local.)|fe80::96b5:55ff:fef7:f108|:8081... failed: Invalid argument.

Same time on PC with ONLY IPv4 enabled. image

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

simphide commented 1 year ago

The problem still exists...

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

simphide commented 1 year ago

The problem still exists...

rmelotte commented 1 year ago

This issue looks similar to https://github.com/home-assistant/core/issues/69669 .

Do you have a firewall on the server running HA that blocks all outgoing ipv6 traffic?

On Debian it was the case by default for me when using ufw for example. In /etc/default/ufw:

# Set to yes to apply rules to support IPv6 (no means only IPv6 on loopback
# accepted). You will need to 'disable' and then 'enable' the firewall for
# the changes to take affect.
IPV6=no

In my case setting it to IPV6=yes followed by disabling and enabling ufw fixes the issue.

jonathanbower commented 1 year ago

In my case setting it to IPV6=yes followed by disabling and enabling ufw fixes the issue.

This worked for me as well. Thanks.

simphide commented 1 year ago

Same! It solved my problem! Thank you very much!