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 the root of my website.

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 that are 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 the top-level directory of your website, where all of your website’s files and folders are stored.

Error message when ads.txt is not found

You might come across 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.’

Let’s check where you can find Ads.txt file Status on Google Adsense portal:

  • On the left-hand side, click on Sites.
  • This will open up Manage your sites page that 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 below screenshot, Ads.txt status column for my site cloudinfra.net shows as Not found. We need to fix this issue as soon as possible and make sure 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 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 have faced this problem when I was using Cloudflare as a Content Delivery Network (CDN) for my website. I’m not completely certain about the exact cause, but it’s possible that Cloudflare restricts direct access to the files on my website as a security measure. However, I can guide you through the steps which helped me resolve this issue for me.

  • Log in to your Cloudflare account where you’ve added your websites
  • From the home page, locate ‘Workers & Pages.’ If you can’t find the home page, simply 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 on ‘Create application,’ and you’ll find the ‘Create Worker’ option under it.”
Click "Create Worker" button
Click “Create Worker” button
  • Give 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
  • 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`;
  • 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 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,” and then click on the name of your website 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” in the path with your site name.
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 to see if you can access the ads.txt file using a web browser. As shown in the screenshot below, the ads.txt file 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 on “Sites” in the left-hand side panel. On the “Manage your sites” page, you will find your site listed with an Ads.txt Status Issue. Click on the site to open a page where you can test for the ads.txt file.
  • Click on the “Check for updates” link to verify if Google can now access the ads.txt file for your site.
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 also shows as Authorized

Leave a Comment