This so sad because a feature that the Yoast team removed from their plugin starting from v7.0 is causing unnecessary inconvenience for their clients. I never knew this error existed until it happened to me. I checked my XML sitemaps in Google search console and I discovered that one part of my XML sitemap generated by Yoast is having the “pending sign”. It amazes me to learn that this sign(which otherwise should be gone within 48 hours)lingers for days. Out of my curiosity, I click the link in other to view the sitemap within my browser and lo and behold, I received an error 502 invalid response/bad gateway message. This post will provide solutions to 500/502 Yoast sitemap errors.
What is a 502 Bad Gateway Error?
Basically, there are many different types of 500 status error codes (500, 501, 502, 503, 504, etc) which all have slightly different meanings. These indicate that the request was accepted, but the server prevented the fulfilment of the request. In this case, a 502 bad gateway error specifically means that one server, while acting as a gateway or proxy, has received an invalid response from an inbound server.
However, in your own case, you may have received an error 500 internal server response. Be it 500 or 502, as long as you are receiving this error while trying to access your XML sitemap generated by Yoast SEO, my tips here would be useful for you.
Especially relevant
- Permanent Solution to Invalid Server Certificate on Google Chrome while Visiting SSL Sites(on Win 8, Win 7 64 bits)
- Solve the backup “iPhone” cannot be restored to this iPhone because the software on this phone is too old” error on iTunes without restoring your iPhone to the latest software
What causes 500/502 Yoast sitemap errors?
The number 1 reason why you get an internal server error or HTTP error 502 while trying to access Yoast “sitemap_index.xml” or any of the individual sitemaps within the index file via a web browser. Below is the list of possible causes of this error:
- Server/Php memory limit issues: Many websites are hosted on shared hosting which has its limitation. By default, Yoast SEO sets its maximum number of entries per sitemap to 1000. This is way too much for what shared hosting providers permits. In the cause of this article, i would teach you how to reduce this max entry. Memory limit of your server can cause an error 500 or 502 for your Yoast sitemap by a whopping 70%.
- Secondly, conflicts with other plugins can cause your sitemap to throw error 500/502. Not only this, your entire website may be inaccessible with just one plugin malfunctioning.
- Thirdly, a cache plugin may conflict with Yoast. This is true of the minify settings of W3C total cache.
- Browsers and plugin cache is another possible cause of 500/502 Yoast sitemap errors.
- Finally, permanent links and wrong rewrite can cause this error to occur.
How and when do 500/502 Yoast sitemap errors occur?
If you frequent your google search console(webmaster tools) you will notice that one or all of your site’s sitemaps have the pending tag. In my case, my “/post-sitemap.xml” is what is giving me the error as you can see from the picture below.
Also, my main XML(sitemap_index.xml), and may pages(page-sitemap.xml) files are working fine. In other cases, it might be any of the XML links like portfolio-sitemap.xml, attachments, category and so on that would be throwing either an error 502 or a “Network unreachable: Network unreachable
HTTP Error: 500”
Additionally, if you click on the affected link(s) you would receive the above error. This error can affect how search engines crawl your site as it may render your pages uncrawlable to search engines.
Furthermore, this google search console may be having issues with all or some of your sitemaps. This you can verify for yourself as you will get a 502/500 error when or if you attempt a visit to that URL. surprisingly, Googlebot says the URL is allowed
Also, some users complain that they started experiencing the errors immediately the upgraded their Yoast SEO plugin. Yoast SEO plugin version 6 or older doesn’t have this issue because you can manually change the entries with the plugin’s dashboard.
How to troubleshoot 500/502 Yoast sitemap errors
Before we go to the fixes, I will teach you how you can troubleshoot error 500 or 502 with Yoast XML Sitemaps.
- First, just disabled all plugins and enabled Yoast SEO as a standalone plugin. Make sure you disable all the other plugins in bulk as against individually. See if this fixes the error. If it does, then check for the conflicting plugins… didn’t fix the issue.
- Secondly, try if the sxl version is working. to do this, replace .xml with .xsl as in: /product-sitemap.xsl instead of /product-sitemap.xsl. In my case, I received a blank page.
- Thirdly, you should disable xml sitemap withing Yoast dashboard(you can find this under; SEO>>general>>features>>then toggle the XML sitemap button off. Next, your browser’s cache. If you installed a cache plugin, clear this as well then enable the XML sitemap again.
- Furthermore, try and reset your permalinks or rewrite rules. We would first recommend trying resetting the permalink structure in WordPress which can be done by performing the following steps: Login to WordPress>>Go to Settings>PermalinksClicking ‘Save Changes’ without making any modifications.
- You can also Check for conflicts.
- Or check for JavaScript errors with your console. If you find any JavaScript errors related to Yoast SEO or if there is a conflict with a plugin or a theme, you can create a new GitHub issue for Yoast developers.
If you didn’t find any conflicts or errors, we think the issue is specific to your site. The fix that I am going to roo out in the preceding section will help you put this to rest for good.
How to Fix 500/502 Yoast sitemap errors easily
Like I said in my introduction, this error is caused largely by PHP memory issues on some sites. Although it can cause by the maximum number of sitemap entries in yoast. Whatever the case may be, the two fixes I am going to proffer here will solve your issue. It is either you increase your PHP execution time and memory limit(if your host permits it), or you reduce the number of sitemap entries per page within the Yoast plugin.
Fix 500/502 Yoast sitemap errors by reducing the Maximum entries per sitemap
I recommend this to those who are on a shared hosting platform. Limiting the number of sitemap entries can prevent issues associated with sitemaps that have become too large; like the server exceeding set PHP memory limits whenever compiling large sitemaps.
The 500/502 Yoast sitemap errors can happen either when you click on your “sitemap_index.xml” file. In the alternative, it can also occur when you click on the individual Sitemaps part of the index file like “post-sitemap.xml”. In most instances, it is due to the PHP script runtime restriction on the host level.
If your web host actually restricts you, then you need to reduce the number of entries in each Sitemap. By default, the number of entries in each Sitemap is restricted to 1000 in Yoast WordPress SEO plugin.
If you use a shared hosting like bluehost, Arvixe, Hostgator and the likes, please reduce the max. entries per Sitemap to 300 or 400. Once you have done this, check that all the Sitemaps are accessible under Sitemap index. When you change the number of entries, all individual Sitemaps like posts, tags, and categories will be restructured accordingly. Hence, it is highly recommended to resubmit your Sitemap to Google search console.
Steps to reduce your max entries per sitemap in Yoast
There are two ways by which you can do this. The first method is through a WordPress plugin known as “code snippet”. The second method is by adding a filter to your theme’s “function.php” file.
Reduce Max entries per Sitemap for Yoast SEO with the “code snippet”
Ever since the release of Yoast SEO v7.0, the ability to input the number of pages per sitemap file through the settings has been removed. It has been replaced with a filter. You can add the filter to your site either via a plugin or in funtion.php.
If you don’t have access to your site’s Cpanel or if you don’t feel comfortable editing these files directly, or you cannot back-up these files before doing so, install and activate Code Snippets and add it as a snippet set to “run everywhere”.
After installing the above plugin, copy the code below as they are into your snippet and set it to run everywhere.
function max_entries_per_sitemap() {
return 300;
}
add_filter( ‘wpseo_sitemap_entries_per_page’, ‘max_entries_per_sitemap’ );
How to reduce the max entries of sitemap in Yoast by adding a filter to functions.php
First, you need to locate the path of your funtions.php. If you use a premium theme, it would be inside your child-theme folder. To navigate to your funtions.php via Cpanel, follow this steps
-Login to your Cpanel
-Locate your file manager
-Open your public_html folder
-Go to wp-content
-Open your themes folder(or your child theme’s folder as the case may be).
-Locate and open your “funtions.php”. Right click and edit. You will see something like what is in the picture below:
-) Finally, copy the code below to the bottom of your “functions.php” file
function max_entries_per_sitemap() {
return 300;
}
add_filter( ‘wpseo_sitemap_entries_per_page’, ‘max_entries_per_sitemap’ );
Where “300” is the number of entries you want to limit your sitemap entries too.
How to solve 500/502 Yoast sitemap errors by increasing the PHP memory size limit of your site
Another equally effective method of solving the XML sitemap error 500 or 502 is for you to increase your site’s PHP runtime limit from within your Cpanel. Warning!! backup the existing file before making any changes. Also, if you can’t do this yourself, you can contact your host to help you with it.
You can achieve this in three ways.
- Increase the limits from your php.ini or php5.ini within your WordPress installation folder
- Secondly, you can do this via your .htaccess.php file
- Another option is for you to edit your wp-config.php file to increase this values.
- Finally and the one that works best in my situation is for you to use your PHO INImultisite editor within your control panel.
I will now explain them individually.
How to increase your PHP memory limit within your Cpanel PHP editor
This method will also take care of your 500/502 Yoast sitemap errors
- Login to your Cpanel,
- Locate “EDIT PHP INI” Icone or anything related to editing PHP INI.
- Next, open it and navigate to the advanced editor
- Increase the value to anything above “64MB” so long as your host supports it.
Method 2: Increase memory limit from php.ine file
Find or manually create a php.ini file in your site root (usually www, public_html or htdocs folder) and add the following line:
memory_limit = 64MB
64MB can be any value that is higher.
Method 3: You can increase the same limit via wp-config.php file
if (!defined(‘WP_MEMORY_LIMIT’))
define(‘WP_MEMORY_LIMIT’,’128M’);
Finally, you can also do this from your .htaccess.php file. The most important thing is that you must increase your PHP memory limit for this error to go away all other things being equal.
The sitemap plugin can facilitate the introduction of the pages or content of my site to search engines. A sitemap is very useful for my blog SEO because a site sitemap can inform the url of the content on my blog to be more easily reached by search engines so that it can be indexed faster.
Thank you so much, the article is very good and useful for me and other readers, my site is better because this plugin is super fast.