question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

1004 DNS Validation Error

See original GitHub issue

I’m getting this error in the log when trying to create the cnames for domain.xyz and www.domainname.xyz

container rule value: Host(domainname.xyz,www.domainname.xyz) extracted_domains from rule: [u’domainname.xyz,www.domainname.xyz’] Found Container: 647e66db859869694c080e371cff0b9bba33e21850d439c5fe3b86a41eb818f7 with Hostname domainname.xyz,www.domainname.xyz ** domainname.xyz,www.domainname.xyz - 1004 DNS Validation Error

organizr container label is Host(domainname.xyz,www.domainname.xyz)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ahmaddxbcommented, Jul 10, 2020

Thanks that worked

0reactions
jathekcommented, Sep 20, 2020

I have a Host rule in the || format that Cloudflare Companion expects and it still throws a 1004 error when encountering my root domain. Is it possible that the code can’t parse the root domain because it doesn’t have a subdomain?

My rule:

- "traefik.http.routers.organizr-rtr.rule=HostHeader(`organizr.$DOMAINNAME`) || HostHeader(`www.$DOMAINNAME`) || HostHeader(`$DOMAINNAME`)"

First two are parsed fine, the last one throws a 1004 error.

EDIT: I enabled debug logs and I think I see something that might cause an issue?

2020-09-20T06:40:40.796794552Z [info] Found Container ID: dcb28d022a374612478c77dac64fc54be3c100a83a32705acd5730a2eb01828a with Multi-Hostname example.com
2020-09-20T06:40:40.798406121Z 2020-09-20 01:40:40,796 - Python Cloudflare API v4 - DEBUG - Call: emulated curl command ...
2020-09-20T06:40:40.798546486Z        curl -X GET "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?name=example.com" \
2020-09-20T06:40:40.798641955Z             -H "User-Agent: python-cloudflare/2.8.13/python-requests/2.24.0/python/3.8.5" \
2020-09-20T06:40:40.798674038Z             -H "Content-Type: application/json" \
2020-09-20T06:40:40.798741903Z             -H "Authorization: REDACTED" 
2020-09-20T06:40:40.934313932Z 2020-09-20 01:40:40,933 - Python Cloudflare API v4 - DEBUG - Response: 200, application/json, b'{"result":[{"id":"$RECORD_ID","zone_id":"$ZONE_ID","zone_name":"example.com","name":"example.com","type":"A","content":"98.253.43.26","proxiable":true,"proxied":true,"ttl":1,"locked":false,"meta":{"auto_added":false,"managed_by_apps":false,"managed_by_argo_tunnel":false,"source":"primary"},"created_on":"2020-09-20T06:15:17.720944Z","modified_on":"2020-09-20T06:15:17.720944Z"},{"id":"$RECORD_ID2","zone_id":"$ZONE_ID","zone_name":"example.com","name":"example.com","type":"TXT","content":"v=spf1 mx ~all","proxiable":false,"proxied":false,"ttl":1,"locked":false,"meta":{"auto_added":false,"managed_by_apps":false,"managed_by_argo_tunnel":false,"source":"primary"},"created_on":"2020-08-18T22:14:26.696523Z","modified_on":"2020-08-18T22:14:26.696523Z"}],"success":true,"errors":[],"messages":[],"result_info":{"page":1,"per_page":20,"count":2,"total_count":2,"total_pages":1}}'
2020-09-20T06:40:40.935163622Z 2020-09-20 01:40:40,934 - Python Cloudflare API v4 - DEBUG - Response: [{'id': '$RECORD_ID', 'zone_id': '$ZONE_ID', 'zone_name': 'example.com', 'name': 'example.com', 'type': 'A', 'content': '98.253.43.26', 'proxiable': True, 'proxied': True, 'ttl': 1, 'locked': False, 'meta': {'auto_added': False, 'managed_by_apps': False, 'managed_by_argo_tunnel': False, 'source': 'primary'}, 'created_on': '2020-09-20T06:15:17.720944Z', 'modified_on': '2020-09-20T06:15:17.720944Z'}, {'id': '$RECORD_ID2', 'zone_id': '$ZONE_ID', 'zone_name': 'example.com', 'name': 'example.com', 'type': 'TXT', 'content': 'v=spf1 mx ~all', 'proxiable': False, 'proxied': False, 'ttl': 1, 'locked': False, 'meta': {'auto_added': False, 'managed_by_apps': False, 'managed_by_argo_tunnel': False, 'source': 'primary'}, 'created_on': '2020-08-18T22:14:26.696523Z', 'modified_on': '2020-08-18T22:14:26.696523Z'}]
2020-09-20T06:40:40.936173731Z 2020-09-20 01:40:40,935 - Python Cloudflare API v4 - DEBUG - Call: emulated curl command ...
2020-09-20T06:40:40.936320502Z        curl -X POST "https://api.cloudflare.com/client/v4/zones/$ZONE/dns_records" \
2020-09-20T06:40:40.936356648Z             -H "User-Agent: python-cloudflare/2.8.13/python-requests/2.24.0/python/3.8.5" \
2020-09-20T06:40:40.936388210Z             -H "Content-Type: application/json" \
2020-09-20T06:40:40.936418679Z             -H "Authorization: REDACTED" \
2020-09-20T06:40:40.936448263Z             --data '{'type': 'CNAME', 'name': 'example.com', 'content': 'example.com', 'ttl': '1', 'proxied': True}' 
2020-09-20T06:40:41.110646948Z 2020-09-20 01:40:41,109 - Python Cloudflare API v4 - DEBUG - Response: 400, application/json, b'{"result":null,"success":false,"errors":[{"code":1004,"message":"DNS Validation Error","error_chain":[{"code":9039,"message":"CNAME content cannot reference itself"}]}],"messages":[]}'
2020-09-20T06:40:41.111994349Z 2020-09-20 01:40:41,110 - Python Cloudflare API v4 - DEBUG - Response: error 9039 CNAME content cannot reference itself - chain
2020-09-20T06:40:41.113061853Z 2020-09-20 01:40:41,111 - Python Cloudflare API v4 - DEBUG - Response: error 1004 DNS Validation Error
2020-09-20T06:40:41.113257374Z ** example.com - 1004 DNS Validation Error

The curl is trying to set a CNAME record for example.com pointing to example.com. I think that’s why the errors are saying that CNAME can’t reference itself.

Probably Cloudflare Companion should just ignore any parsed hostname that is an exact match for the TARGET_DOMAIN environment variable.

EDIT 2: I got rid of the error by changing TARGET_DOMAIN=$DOMAIN to TARGET_DOMAIN=ddns.$DOMAIN. Now when it tries to create a CNAME for example.com it will point to ddns.example.com so Cloudflare won’t mind. But probably the container should still have a contingency for when TARGET_DOMAIN is equal to the CNAME name. If this contingency isn’t put in place then it will cause issues with #13, since ddns will now need to be whitelisted and ignored somehow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Community Tip - Fixing Code 1004: DNS Validation Error
A Code 1004 error while working on the Cloudflare dashboard indicates that Cloudflare was unable to complete a requested action. This is a ......
Read more >
Error: DNS Validation Error (Code: 1004) - SendGrid Support
Users may see DNS Validation Error (Code: 1004) when using a CNAME record that is not available via the public internet. This guide...
Read more >
Tips to fix cloudflare code 1004 - Bobcares
Error with the DNS records. The most common reason for the Cloudflare code 1004 is an error with the DNS record that the...
Read more >
[Solved] DNS Validation Error (Code: 1004): CNAME content ...
DNS Validation Error (Code: 1004): CNAME content cannot be an IP (Code: 9040) - You are getting this error because you added you...
Read more >
DNS validation error code 1004 this record type cannot be ...
DNS validation error code 1004 this record type cannot be proxied .this error happens while adding some records in your Cloudflare DNS ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found