I can't get rid of my 522

I can’t seem to get my Cloudflare tunnel to connect to my Home Assistant. Can anyone figure out what I have wrong? I’ve searched everywhere and can’t find a solution.

Here’s my config.yaml for Home Assistant

Loads default set of integrations. Do not remove.

default_config:

This is for Cloudflare to enable external access to Home Assistant

http:
use_x_forwarded_for: true
ssl_certificate: /config/origin.pem
ssl_key: /config/privkey.pem
trusted_proxies:
- 103.21.244.0/22
- 103.22.200.0/22
- 103.31.4.0/22
- 104.16.0.0/13
- 104.21.71.39
- 104.24.0.0/14
- 108.162.192.0/18
- 131.0.72.0/22
- 141.101.64.0/18
- 162.158.0.0/15
- 172.30.33.0/24
- 172.64.0.0/13
- 172.67.143.21
- 173.245.48.0/20
- 188.114.96.0/20
- 190.93.240.0/20
- 197.234.240.0/22
- 198.41.128.0/17
server_port: 8443

homeassistant:
internal_url: “http://192.168.86.25:8443

Text-to-speech

tts:

  • platform: google_translate

ecobee:
api_key: 3f9RUVkdtq2GzSajHxLanhT9i3mQsg7J

Ecobee pin: MRNL-FFSH

Load frontend themes from the themes folder

frontend:
themes: !include_dir_merge_named themes

script: !include scripts.yaml
scene: !include scenes.yaml

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
input_number helpers
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
input_number: !include input-numbers/input-numbers.yml
#
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#* counter helpers
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
counter: !include counters/counters.yml
#
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#* input_text helpers
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
input_text: !include input-text/input-text.yml
#
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#* input_boolean helpers
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
input_boolean: !include boolean/booleans.yml
#
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#* input_button helpers
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
input_button: !include input-buttons/input-buttons.yml
#
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#* input_select helpers
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
input_select: !include input-selects/input-selects.yml
#
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#* Automations
#*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
automation: !include_dir_merge_list automations/

This is my Cloudflare setup:




I get these messages every hour in my /var/log/syslog file
2023-12-03 09:02:22.747 DEBUG (MainThread) [homeassistant.components.cloudflare] Starting update for zone doghome.casa
2023-12-03 09:02:23.029 DEBUG (MainThread) [pycfdns] {‘result’: [{‘id’: ‘e5530ba569029da28d031b66dd21f918’, ‘zone_id’: ‘155b67ad813bffff37c7b5a9e5819057’, ‘zone_name’: ‘doghome.casa’, ‘name’: ‘ha.doghome.casa’, ‘type’: ‘A’, ‘content’: ‘99.127.80.184’, ‘proxiable’: True, ‘proxied’: True, ‘ttl’: 1, ‘locked’: False, ‘meta’: {‘auto_added’: False, ‘managed_by_apps’: False, ‘managed_by_argo_tunnel’: False, ‘source’: ‘primary’}, ‘comment’: None, ‘tags’: , ‘created_on’: ‘2023-11-12T23:42:39.406531Z’, ‘modified_on’: ‘2023-11-14T21:24:23.805659Z’}], ‘success’: True, ‘errors’: , ‘messages’: , ‘result_info’: {‘page’: 1, ‘per_page’: 100, ‘count’: 1, ‘total_count’: 1, ‘total_pages’: 1}}
2023-12-03 09:02:23.209 DEBUG (MainThread) [pycfdns] {‘result’: [{‘id’: ‘d8a572a5e1e65808c8a1adb4c3a445c5’, ‘zone_id’: ‘155b67ad813bffff37c7b5a9e5819057’, ‘zone_name’: ‘doghome.casa’, ‘name’: ‘www.doghome.casa’, ‘type’: ‘A’, ‘content’: ‘99.127.80.184’, ‘proxiable’: True, ‘proxied’: True, ‘ttl’: 1, ‘locked’: False, ‘meta’: {‘auto_added’: False, ‘managed_by_apps’: False, ‘managed_by_argo_tunnel’: False, ‘source’: ‘primary’}, ‘comment’: None, ‘tags’: , ‘created_on’: ‘2023-11-13T01:03:52.755338Z’, ‘modified_on’: ‘2023-11-14T19:19:01.406868Z’}], ‘success’: True, ‘errors’: , ‘messages’: , ‘result_info’: {‘page’: 1, ‘per_page’: 100, ‘count’: 1, ‘total_count’: 1, ‘total_pages’: 1}}
2023-12-03 09:02:23.210 DEBUG (MainThread) [homeassistant.components.cloudflare] Records: [<pycfdns.models.CFRecord object at 0x7fef94af1c90>, <pycfdns.models.CFRecord object at 0x7fef9756af50>]
2023-12-03 09:02:23.290 DEBUG (MainThread) [pycfdns] No need to update record (ha.doghome.casa) content did not change
2023-12-03 09:02:23.291 DEBUG (MainThread) [pycfdns] No need to update record (www.doghome.casa) content did not change
2023-12-03 09:02:23.291 DEBUG (MainThread) [homeassistant.components.cloudflare] Update for zone doghome.casa is complete
The docker logs cloudflared command gives me this information:
2023-12-04T09:00:40Z ERR Failed to create new quic connection error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=2 event=0 ip=198.41.200.13
2023-12-04T09:00:40Z INF Retrying connection in up to 8s connIndex=2 event=0 ip=198.41.200.13
2023-12-04T09:00:40Z ERR Failed to create new quic connection error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=1 event=0 ip=198.41.192.167
2023-12-04T09:00:40Z ERR Failed to create new quic connection error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=0 event=0 ip=198.41.200.233
2023-12-04T09:00:40Z INF Retrying connection in up to 8s connIndex=1 event=0 ip=198.41.192.167
2023-12-04T09:00:40Z INF Retrying connection in up to 8s connIndex=0 event=0 ip=198.41.200.233
2023-12-04T09:00:41Z ERR Connection terminated error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=1
2023-12-04T09:00:43Z ERR Connection terminated error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=2
2023-12-04T09:00:46Z ERR Connection terminated error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=3
2023-12-04T09:00:47Z ERR Connection terminated error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=0
2023-12-04T09:00:54Z ERR Failed to create new quic connection error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=3 event=0 ip=198.41.192.27
2023-12-04T09:00:54Z INF Retrying connection in up to 16s connIndex=3 event=0 ip=198.41.192.27
2023-12-04T09:00:54Z ERR Failed to create new quic connection error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=2 event=0 ip=198.41.200.43
2023-12-04T09:00:54Z INF Retrying connection in up to 16s connIndex=2 event=0 ip=198.41.200.43
2023-12-04T09:00:54Z ERR Failed to create new quic connection error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=1 event=0 ip=198.41.192.77
2023-12-04T09:00:54Z INF Retrying connection in up to 16s connIndex=1 event=0 ip=198.41.192.77
2023-12-04T09:00:54Z INF

===================================================================================
You are hitting an error while using the experimental post-quantum tunnels feature.

Please check:

https://pqtunnels.cloudflareresearch.com

for known problems.

2023-12-04T09:00:54Z ERR Failed to create new quic connection error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=0 event=0 ip=198.41.200.193
2023-12-04T09:00:54Z INF Retrying connection in up to 16s connIndex=0 event=0 ip=198.41.200.193
2023-12-04T09:00:56Z ERR Connection terminated error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=0
2023-12-04T09:01:00Z ERR Connection terminated error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=2
2023-12-04T09:01:00Z ERR Connection terminated error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=1
2023-12-04T09:01:07Z ERR Connection terminated error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=3
2023-12-04T09:01:51Z ERR Failed to create new quic connection error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=1 event=0 ip=198.41.192.47
2023-12-04T09:01:51Z INF Retrying connection in up to 32s connIndex=1 event=0 ip=198.41.192.47
2023-12-04T09:01:51Z ERR Failed to create new quic connection error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=3 event=0 ip=198.41.192.167
2023-12-04T09:01:51Z INF Retrying connection in up to 32s connIndex=3 event=0 ip=198.41.192.167
2023-12-04T09:01:51Z ERR Failed to create new quic connection error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=0 event=0 ip=198.41.200.33
2023-12-04T09:01:51Z INF Retrying connection in up to 32s connIndex=0 event=0 ip=198.41.200.33
2023-12-04T09:01:51Z ERR Failed to create new quic connection error=“failed to dial to edge with quic: timeout: no recent network activity” connIndex=2 event=0 ip=198.41.200.233
2023-12-04T09:01:51Z INF Retrying connection in up to 32s connIndex=2 event=0 ip=198.41.200.233

I am running Casaos on a Zima Board. I finally fixed it. I reinstalled cloudflare in a Docker container with a command provided by the Cloudflare Zero Trust dialog Access → Tunnels. It looked like this.

docker run -d cloudflare/cloudflared:latest tunnel --no-autoupdate run --token eyJhIjoiNTczZGE1YzFjOTM0YmQyZjI1YWQ4MTMwN2FjZDI1ZWEiLCJ0IjoiODlkYzA2ZTctODRkOS00ZjViLTgyODYtOTA4NWM1ZDUxZjljIiwicyI6Ik9ETXpOV0U0WkdJdFl6WXdNaTAwWkRsbUxUbGpZalV0TVdNd1lUZGlPRFxxxxxxxxxx

I had to add the -d flag to keep it running past the terminal window exit.

When configuring Cloudflare:
In Zero Trust, configure tunnels - Don’t do anything in DNS (Which is not in Zero Trust)
In Zero Trust, don’t do anything in Applications, Access Groups, Service Auth or Tags
Sample Tunnel Def:
Tunnel Name: homeassistant
Environment: Docker
Click on Public Hostname
Add a Hostname

To get API Token, go to Cloudflare Cloudflare API Token Link
Use Add Integration in Home Assistant Devices & Services and find Cloudflare.
Use the API token above

Use this with your token to test your tunnel.
curl -X GET “https://api.cloudflare.com/client/v4/user/tokens/verify
-H “Authorization: Bearer your token here”
-H “Content-Type:application/json”

You should see something like → success":true

In Home Assistant, I checked Settings → System → Logs and found my /Data/AppData/homeassistant/config/configuration.yaml needed these lines.

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 192.168.86.25  # This is the ip address of my Home Assistant Server and Cloudflare of course
  server_port: 8443 

You might try a dig command as well. You should see cloudflare server ip addreses
image

This is how I fixed my issue. Good luck!

Hi.

I haven’t read everything, but I can see 2 things that might help you:

  • Your DNS record for the ha subdomain is wrong. Cloudflare tunnel automatically creates DNS records, and it would definitely not be an A record that contains your IP address.
    Delete the record and recreate the tunnel, this should automatically create a CNAME record.
  • You use Cloudflare’s IPs with the trusted_proxies directive. However, when using a tunnel, requests to your webserver are not made from Cloudflare IPs, but the IP of the device running the tunnel.
    If the tunnel is running on the same device as Home Assistant, that would be 127.0.0.1, otherwise your local network address.

Edit: Oops, didn’t notice you found the solution by yourself in the 2nd post. I should finish reading before posting ~.~

Ah, but I do appreciate your reply. It would have gotten me there. Thank you!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.