How to fix Ads.txt not found Issue when using Cloudflare

I recently encountered a problem on the Google AdSense portal. It showed that my site’s Ads.txt status was Not found. I confirmed that I had placed the ads.txt file correctly at my website’s root.

However, when I tried to access this file using a web browser via https://cloudinfra.net/ads.txt, it displayed an error message: Oops! That page can’t be found.

ads.txt file not found error
ads.txt file not found error

What is ads.txt file?

The ads.txt (Authorized Digital Sellers) file is a simple text file that publishers in the digital advertising ecosystem use to publicly declare the companies or entities authorized to sell their digital advertising inventory. This file is placed on a publisher’s website and is meant to combat fraud and domain spoofing in programmatic advertising.

ads.txt file must be placed in the root directory of your website. The root directory is your website’s top-level directory, storing all your files and folders.

Error message when ads.txt is not found

You might encounter an error message in the Google AdSense console that says, Earnings at risk—You need to resolve some issues with your ads.txt file to prevent a significant impact on your earnings. You’ll have two options: FIX NOW and LEARN MORE.

Where you can find the Ads.txt file Status on the Google Adsense portal:

  • Sign in to the Google AdSense portal.
  • On the left-hand side, click on Sites.
  • This will open up the Manage Your Sites page, which shows all your sites integrated with Google AdSense.
  • You can check your Site’s Approval Status and Ads.txt status as well.

As you can see in the screenshot below, the Ads.txt status column for my site cloudinfra.net shows as Not Found. We must fix this issue immediately and ensure Ads.txt status remains Authorized.

Google adsense Ads.txt status showing as Not found
Google AdSense Ads.txt status showing as Not found
  • You can click on your site’s name link in the Site URL column and then select Check for updates.
Re-validate ads.txt file status by clicking on Check for updates link
Re-validate ads.txt file status by clicking on Check for Updates link
  • If Google cannot access your site’s ads.txt file using this URL: https://<your site name>/ads.txt, you may receive the following error message:

Couldn’t find an ads.txt file. We tried looking for cloudinfra.net/ads.txt but couldn’t find a file. Please make sure you have uploaded the file correctly and it is available to the Google Adsense crawler.

Couldn't find an ads.txt file error
Couldn’t find an ads.txt file error

You may also find one of the following Ads.txt file status on your Google AdSense portal. Today, we’re concentrating on resolving the Not found error.

  • Not found: No ads.txt file was found when the site was last crawled.
  • Authorised: Your publisher ID was found in the site’s ads.txt file.
  • Unauthorised: You publisher ID wasn’t found in the ads.txt file, and AdSense can’t show ads.
  • Not applicable: Your publisher ID isn’t needed in the ads.txt file.

Steps to fix ads.txt not found Issue

I faced this problem when using Cloudflare as a Content Delivery Network (CDN) for my website. I’m not completely certain about the exact cause, but Cloudflare may restrict direct access to the files on my website as a security measure. However, I can show you the steps that helped resolve this issue.

  • Sign in to your Cloudflare account, where you’ve added your websites.
  • Locate Workers & Pages from the home page. If you can’t find the home page, click on the Cloudflare logo.
Create a Worker in Cloudflare
Create a Worker in Cloudflare
  • Click on Overview and then select Create Worker.
  • If you don’t see the Create Worker option on the Overview page, click Create application, and you’ll find it under the Create Worker option.
Click "Create Worker" button
Click Create Worker button
  • Give the Worker a distinct name. For instance, I’ve used cloudinfraadstxt as the name. Then, click the Deploy button to initiate the deployment of the Worker.
Provide a Name and click on Deploy button to deploy the worker application
Provide a Name and click on Deploy button to deploy the worker application
  • As shown in the screenshot below, the Worker has been successfully deployed. Now, click on the Configure Worker button.
Click on 'Configure Worker' button
Click on ‘Configure Worker’ button
  • After you’ve clicked on Configure Worker, proceed by clicking the Quick edit button.
Click on 'Quick edit' button
Click on Quick edit button
  • Please start by selecting all the default code in the Worker.js file and deleting it. Then, replace that deleted code with the provided code below.
  • Make sure to substitute Add your Google AdSense / third-party Publisher ID info with your actual Google AdSense Publisher ID.
Select the code in Worker.js file and delete all the code
Select the code in Worker.js file and delete all the code
async function handleRequest(request) {
  const init = {
    headers: {
      'content-type': 'text/plain',
    },
  }
  return new Response(adstxt, init)
}
addEventListener('fetch', event => {
  return event.respondWith(handleRequest(event.request))
})
const adstxt =  `Add your google adsense / third party Publisher ID info`;
  • The code has been replaced, and I have added my site’s Google publisher ID Information between the quotes.
Replace the code and update google adsense published ID info
Replace the code and update google adsense published ID info
  • Now, on the right-hand side, click the Send button. You should observe a status code of 200. Finally, click on Save and deploy to deploy this application.
Click on Send button to get a Status code of 200 and then click Save and Deploy
Click on Send button to get a Status code of 200 and then click Save and Deploy
  • Click on the Save and Deploy button again.
Click on Save and deploy button again
Click on Save and deploy button again
  • On your Cloudflare dashboard, navigate to Websites, then click on your website’s name on the home page.
Access your Site container under Websites on cloudflare portal
Access your Site container under Websites on Cloudflare portal
  • On the left-hand side options, select Worker Routes, and then click on the Add route button from the Worker Routes page.
Under Worker Route, Select Add route to add a route for this application
Under Worker Route, Select Add route to add a route for this application
  • In the Route option, enter the URL for the ads.txt file, for example: https://cloudinfra.net/ads.txt. You can replace cloudinfra.net with your site name in the path.
Add a route for ads.txt file
Add a route for ads.txt file
  • Worker Route has been successfully added.
Worker Route has been added successfully
Worker Route has been added successfully

Checking ads.txt File Access via a Web Browser

You can now test whether you can access the ads.txt file using a web browser. As shown in the screenshot below, it is now accessible.

Test ads.txt file access from a web browser to confirm accessibility
Test ads.txt file access from a web browser to confirm accessibility
  • Next, visit the Google AdSense portal and click Sites in the left-hand panel. The Manage your sites page lists your site as having an Ads.txt Status Issue. Click on the site to open a page to test for the ads.txt file.
  • Click the Check for updates link to verify whether Google can access your site’s ads.txt file.
Verify ads.txt accessibility from Google AdSense portal again
Verify ads.txt accessibility from Google AdSense portal again
  • As you can observe, Google has successfully located the Ads.txt file.
Ads.txt found by Google for your website
Ads.txt found by Google for your website
  • Furthermore, if you go back to the Sites section and check the Ads.txt Status, it should now be listed as Authorized.
Also Ads.txt status column also shows as Authorized
Also, Ads.txt status column shows as Authorized

1 thought on “How to fix Ads.txt not found Issue when using Cloudflare”

  1. I tried everything you wrote in the blog and this does help with getting google adsense to work. I’m going to bookmark this page incase I find someone else with the same issue I had with getting the ads.txt on the website I have with cloudflare.

    Reply

Leave a Comment