{"id":1967040,"date":"2025-10-06T07:01:50","date_gmt":"2025-10-06T11:01:50","guid":{"rendered":"https:\/\/theeventscalendar.com\/knowledgebase\/?p=1967040"},"modified":"2026-04-14T14:15:40","modified_gmt":"2026-04-14T18:15:40","slug":"troubleshooting-502-error","status":"publish","type":"post","link":"https:\/\/theeventscalendar.com\/knowledgebase\/troubleshooting-502-error\/","title":{"rendered":"Troubleshooting 502 and 503 errors with The Events Calendar"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"h-502-bad-gateway-errors\">502 Bad Gateway Errors<\/h2>\n\n\n\n<p>A \u201c502 Bad Gateway\u201d (or sometimes \u201c502 Proxy Error\u201d) is an HTTP status code indicating that a server functioning as a <strong>gateway or proxy<\/strong> received an invalid or no response from an upstream server.<\/p>\n\n\n\n<p>In simpler terms: your browser sends a request \u2192 it hits a server or proxy \u2192 that server tries to pass it along (to a PHP process, database, or another service) \u2192 but the upstream component fails or times out \u2192 so the gateway returns 502.<\/p>\n\n\n\n<p>Because calendar pages tend to involve complex queries (dates, recurrences, filters), they can be more vulnerable to pushing against resource limits. Also, in some cases the error isn\u2019t limited to calendar pages: when editing or saving an unrelated page, or viewing other pages after some activity, triggers a 502 error.<\/p>\n\n\n\n<p>Follow these steps to diagnose the problem.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. Turn on Debugging + Check Logs<\/h4>\n\n\n\n<p>Start by enabling WordPress debug output in <code>wp-config.php<\/code>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\ndefine(&#039;WP_DEBUG&#039;, true);\ndefine(&#039;WP_DEBUG_LOG&#039;, true);\ndefine(&#039;WP_DEBUG_DISPLAY&#039;, false);\n<\/pre><\/div>\n\n\n<p>With this, WordPress writes internal errors to the file <code>wp-content\/debug.log<\/code>. Check this file for PHP errors, fatal crashes, or warnings.<\/p>\n\n\n\n<p>Parallel to that, examine your server\u2019s logs (web server error logs, PHP-FPM logs, proxy logs). Look for entries like \u201cupstream timeout\u201d, \u201cconnection refused\u201d, \u201ckilled process\u201d, or segmentation faults.<\/p>\n\n\n\n<p><a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/how-to-enable-debugging-in-wordpress\/\">Here<\/a> is the complete guide.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. Reproduce the Error in a Minimal Setup<\/h4>\n\n\n\n<p>Deactivate all plugins except The Events Calendar plugin. Switch your theme temporarily to a default WordPress theme (Twenty Twenty, Twenty Twenty-Three, etc.). Now try accessing the calendar page.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If the error vanishes, you likely have a plugin or theme conflict interfering with TEC.<\/li>\n\n\n\n<li>If the error remains, it&#8217;s more likely an infrastructure or configuration problem.<\/li>\n<\/ul>\n\n\n\n<p>Once you confirm it&#8217;s caused by a plugin\/theme, reactivate them one by one (or in small batches), each time retesting the calendar page. This way you\u2019ll isolate which component causes the failure.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3. Inspect Database \/ Heavy Queries<\/h4>\n\n\n\n<p>Calendar pages often run complex queries:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Fetching events over date ranges<\/li>\n\n\n\n<li>Processing recurring events<\/li>\n\n\n\n<li>Filtering by categories, venues, organizers<\/li>\n\n\n\n<li>Merging or deduplicating results<\/li>\n<\/ul>\n\n\n\n<p>Use a query <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/how-to-find-and-share-slow-database-queries-in-wordpress\/\">profiling tool<\/a> such as Query Monitor to see which queries on the calendar view are taking long or failing entirely.<\/p>\n\n\n\n<p>If one query is extremely slow, that may cause PHP or the upstream to time out or be killed. If that&#8217;s the case, open a support ticket and share the slow queries with us.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-4-increase-resource-timeout-limits\">4. Increase Resource \/ Timeout Limits<\/h4>\n\n\n\n<p>If the failure seems to originate from long or heavy operations, try <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/resolved-allowed-memory-size-exhausted\/\">increasing limits<\/a> temporarily:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In <code>php.ini<\/code> or <code>.htaccess<\/code> (if allowed): increase <code>memory_limit<\/code>, <code>max_execution_time<\/code>, <code>max_input_vars<\/code>, <\/li>\n<\/ul>\n\n\n\n<p>After applying those changes, retest the calendar page. If it now works (or fails less), then resource limits are a contributing factor.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-5-check-proxy-reverse-proxy-cdn-layers\">5. Check Proxy \/ Reverse Proxy \/ CDN Layers<\/h4>\n\n\n\n<p>If your site runs behind a proxy, load balancer, or CDN (e.g. Cloudflare, Varnish, NGINX in front, etc.), temporarily bypass or disable them and test again.<\/p>\n\n\n\n<p>Misconfiguration or aggressive timeouts in these layers sometimes terminate the request prematurely, even if the backend is working fine.<\/p>\n\n\n\n<p>Also verify that rewrite rules or routing rules for TEC calendar endpoints are not accidentally redirecting or misrouting through a failing upstream.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-6-engage-your-host-infrastructure-team\">6. Engage Your Host \/ Infrastructure Team<\/h4>\n\n\n\n<p>If you still can&#8217;t isolate the cause, bring your collected logs, query profiles, and reproduction steps to your hosting or infrastructure provider. They may have deeper insight:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Internal server logs or crash dumps<\/li>\n\n\n\n<li>Resource usage metrics (CPU, memory, I\/O)<\/li>\n\n\n\n<li>Limits enforced at server level (e.g. process timeouts, memory caps)<\/li>\n<\/ul>\n\n\n\n<p>In many cases, hosts have tools or insights not accessible to you, and they can adjust lower-level settings or monitor processes in real time.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-resolving-the-issue\">Resolving the Issue<\/h3>\n\n\n\n<p>Once you have some idea where the failure lies, here are common fixes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Fix plugin\/theme conflict<\/strong>: disable or replace the offending plugin, or correct faulty theme code that interacts with TEC.<\/li>\n\n\n\n<li><strong>Optimize calendar queries \/ event logic<\/strong>: limit the number of events to show per page and per day in&nbsp;<em>Month View<\/em> under <strong>Events \u2192 Settings \u2192 Display<strong> \u2192Calendar<\/strong><\/strong><\/li>\n\n\n\n<li><strong>Increase server and PHP limits<\/strong>: raise memory, max execution time, process counts.<\/li>\n\n\n\n<li><strong>Tweak proxy \/ server config<\/strong>: increase timeouts and buffer sizes in NGINX \/ load balancer, make sure proxy passes requests correctly.<\/li>\n\n\n\n<li><strong>Temporarily disable caching \/ proxy layers<\/strong>: bypass caching or CDN to confirm they aren\u2019t interfering.<\/li>\n\n\n\n<li><strong>Rollback updates<\/strong>: if the issue began after updating TEC, WordPress, or PHP, consider <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/accessing-older-plugin-versions\/\">rolling back<\/a> (in <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/creating-and-using-a-wordpress-staging-site\/\">staging<\/a> first) to see if that resolves the error.<\/li>\n\n\n\n<li><strong>Collaborate with host support<\/strong>: sometimes only the host can change deep kernel or infrastructure settings to prevent process kills or crashes.<\/li>\n<\/ul>\n\n\n\n<p>A 502 error on TEC\u2019s calendar page often indicates a breakdown somewhere in the chain, from server to PHP to database or proxy. Because calendar pages tend to be among the heavier, more complex requests, they tend to stress limits.<\/p>\n\n\n\n<p>The key is <strong>systematic debugging<\/strong>: logs \u2192 minimal setup \u2192 query profiling \u2192 resource tuning \u2192 proxy checks \u2192 host support.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-http-503-service-unavailable-errors\">HTTP 503 \/ \u201cService Unavailable\u201d Errors<\/h2>\n\n\n\n<p>When your WordPress site shows a <strong>503 Service Unavailable<\/strong> error, it means the server (or some part of the stack) is currently <strong>unable to handle the request<\/strong>. Unlike a 500 error, it usually implies a <strong>temporary<\/strong> condition (overload, maintenance, resource exhaustion) rather than a broken script.<\/p>\n\n\n\n<p>The HTTP 503 status code means the server isn\u2019t ready to handle your request, often because:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It\u2019s under maintenance (some administrators purposefully return 503 during updates or deploys).<\/li>\n\n\n\n<li>It\u2019s overloaded, or some resource (CPU, memory, processes) is exhausted.<\/li>\n\n\n\n<li>A plugin, theme, or custom code is misbehaving and exhausting resources, triggering server failure.<\/li>\n<\/ul>\n\n\n\n<p>Importantly, a 503 is a <strong>server-side<\/strong> error. It doesn\u2019t inherently tell you <em>which<\/em> component failed. That\u2019s why you need to troubleshoot.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-common-causes\">Common Causes<\/h3>\n\n\n\n<p>These are frequent culprits behind 503 errors in WP environments:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Plugin conflicts \/ resource-intensive plugins<\/strong><br>A poorly coded or heavy plugin may consume too many resources or trigger fatal errors. Many guides suggest deactivating all plugins to isolate the issue.<\/li>\n\n\n\n<li><strong>Theme issues \/ custom code in theme<\/strong><br>The active theme (or functions in it) might introduce logic that fails or overloads the server. Switching to a default theme is a common troubleshooting step.<\/li>\n\n\n\n<li><strong>Server resource limitations \/ overload<\/strong><br>Shared hosting often imposes memory, process, or CPU limits. If your site\u2019s demands exceed those, you\u2019ll get 503 errors.<\/li>\n\n\n\n<li><strong>Excessive processes \/ background jobs \/ cron tasks<\/strong><br>Too many concurrent tasks (cron, background operations, long-running queries) can overwhelm the server.&nbsp;<\/li>\n\n\n\n<li><strong>Problems with caching, CDN, or server proxy layers<\/strong><br>Sometimes caching \/ CDN \/ reverse proxy misconfiguration can lead to 503 responses. Disabling or bypassing them helps isolate whether the issue lies there.&nbsp;<\/li>\n\n\n\n<li><strong>Errors in PHP version \/ server configuration<\/strong><br>Upgrades, misconfigured PHP settings may cause 503.<\/li>\n\n\n\n<li><strong>Third-party plugin or service causing fatal errors<\/strong><br>In some cases, plugins can cause 503s when activated.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-diagnosing-a-503-error\">Diagnosing a 503 Error<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1. Check Status &amp; Server \/ Host<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ask the host to inspect server logs to see if resource limits or fatal errors appear.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. Enable WP Debug \/ Logging<\/h4>\n\n\n\n<p>Add to <code>wp-config.php<\/code>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\ndefine(&#039;WP_DEBUG&#039;, true);\ndefine(&#039;WP_DEBUG_LOG&#039;, true);\ndefine(&#039;WP_DEBUG_DISPLAY&#039;, false);\n<\/pre><\/div>\n\n\n<p>This makes WordPress write errors to <code>wp-content\/debug.log<\/code> without exposing them publicly.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3. Deactivate All Plugins<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Disable all plugins.<\/li>\n\n\n\n<li>Check whether the site returns.<\/li>\n\n\n\n<li>If yes, enable plugins one by one (or in small groups) to find the culprit plugin.&nbsp;<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">4. Switch Theme to Default<\/h4>\n\n\n\n<p>If disabling plugins doesn&#8217;t resolve it:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enable one of the WP default themes, such as Twenty Twenty-Five.<\/li>\n\n\n\n<li>Then test the site. If it returns, the issue was in your theme.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">5. Temporarily Disable CDN \/ Caching \/ Reverse Proxy<\/h4>\n\n\n\n<p>If you use a CDN or caching layer (Cloudflare, etc.):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Pause or disable it temporarily.<\/li>\n\n\n\n<li>Purge caches.<\/li>\n\n\n\n<li>Test if the site comes back.<\/li>\n\n\n\n<li>If it does, the issue is in caching \/ proxy layer or the interface between it and your origin server.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">6. Inspect Background Work \/ Cron \/ Processes<\/h4>\n\n\n\n<p>If everything above fails:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check running processes on server.<\/li>\n\n\n\n<li>Inspect scheduled WP cron jobs (via plugin like <a href=\"https:\/\/wordpress.org\/plugins\/wp-crontrol\/\">WP Crontrol<\/a>).<\/li>\n\n\n\n<li>Check if a heavy, long query or loop is saturating the server.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-7-review-php-server-configuration-amp-versions\">7. Review PHP \/ Server Configuration &amp; Versions<\/h4>\n\n\n\n<p>Check for mismatches or misconfiguration:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensure PHP version is supported and settings like <code>memory_limit<\/code>,&nbsp;<code>max_execution_time<\/code> are adequate.<\/li>\n\n\n\n<li>If recently upgraded PHP, verify all modules and settings were enabled correctly.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-how-to-fix-resolve-the-503-error\">How to Fix \/ Resolve the 503 Error<\/h3>\n\n\n\n<p>Once you isolate or suspect a cause, try these solutions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Remove or replace the faulty plugin<\/strong><br>If a particular plugin caused it, deactivate or uninstall it, and look for alternatives.<\/li>\n\n\n\n<li><strong>Fix or remove problematic theme code<\/strong><br>If the theme was the cause, either correct the code or switch to a more stable theme.<\/li>\n\n\n\n<li><strong>Increase server resources<\/strong><br>Ask your host to allocate more memory, CPU, processes, or move to a higher tier. Many 503s are caused by shared hosting hitting limits.&nbsp;<\/li>\n\n\n\n<li><strong>Fix background tasks \/ limit them<\/strong><br>Reduce how many concurrent tasks run, optimize cron jobs, disable heavy scheduled tasks or plugins that do many background operations.<\/li>\n\n\n\n<li><strong>Correct CDN \/ caching configuration<\/strong><br>Ensure proxy \/ caching layers pass through appropriate headers, don\u2019t block origin, or misinterpret the site\u2019s backend responses.<\/li>\n\n\n\n<li><strong>Adjust PHP \/ server settings<\/strong><br>Increase <code>memory_limit<\/code> and <code>max_execution_time<\/code>.<\/li>\n\n\n\n<li><strong>Restore from backup (if necessary)<\/strong><br>If recent changes caused 503s (bad update, broken custom code), restore to a known working version.<\/li>\n\n\n\n<li><strong>Ask hosting support \/ sysadmin help<\/strong><br>If you can\u2019t find the cause, host support can examine deeper logs, monitor process usage, or detect server-level issues.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-errors-in-google-search-console\">Errors in Google Search Console<\/h2>\n\n\n\n<p>5xx errors in Google Search Console don&#8217;t always mean your site is currently broken. Search Console logs errors at the time Google crawled the page, which may have been during a brief outage. Before troubleshooting, visit each flagged URL directly. If the pages load correctly now, the errors are simply outdated \u2014 Google will update its records on the next crawl. If the pages are still failing, work through the diagnostic steps above.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>502 Bad Gateway Errors A \u201c502 Bad Gateway\u201d (or sometimes \u201c502 Proxy Error\u201d) is an HTTP status code indicating that a server functioning as a gateway or proxy received an invalid or no response from an upstream server. In simpler terms: your browser sends a request \u2192 it hits a server or proxy \u2192 that&#8230;<\/p>\n","protected":false},"author":27,"featured_media":1955565,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_swpsp_post_exclude":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"ep_exclude_from_search":false,"footnotes":""},"categories":[93],"tags":[283,259],"stellar-product-taxonomy":[158,161],"class_list":["post-1967040","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-errors","tag-errors","tag-troubleshooting","stellar-product-taxonomy-events-calendar-pro","stellar-product-taxonomy-the-events-calendar"],"acf":[],"taxonomy_info":{"category":[{"value":93,"label":"Troubleshooting"}],"post_tag":[{"value":283,"label":"Errors"},{"value":259,"label":"Troubleshooting"}],"stellar-product-taxonomy":[{"value":158,"label":"Events Calendar Pro"},{"value":161,"label":"The Events Calendar"}]},"featured_image_src_large":["https:\/\/images.theeventscalendar.com\/kb\/uploads\/2023\/02\/social-share-1024x538.png",1024,538,true],"author_info":{"display_name":"Abz","author_link":"https:\/\/theeventscalendar.com\/knowledgebase\/author\/abz\/"},"comment_info":0,"category_info":[{"term_id":93,"name":"Troubleshooting","slug":"errors","term_group":0,"term_taxonomy_id":93,"taxonomy":"category","description":"","parent":0,"count":52,"filter":"raw","term_order":"0","cat_ID":93,"category_count":52,"category_description":"","cat_name":"Troubleshooting","category_nicename":"errors","category_parent":0}],"tag_info":[{"term_id":283,"name":"Errors","slug":"errors","term_group":0,"term_taxonomy_id":283,"taxonomy":"post_tag","description":"","parent":0,"count":2,"filter":"raw","term_order":"0"},{"term_id":259,"name":"Troubleshooting","slug":"troubleshooting","term_group":0,"term_taxonomy_id":259,"taxonomy":"post_tag","description":"","parent":0,"count":10,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1967040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1967040"}],"version-history":[{"count":6,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1967040\/revisions"}],"predecessor-version":[{"id":1969046,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1967040\/revisions\/1969046"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1967040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1967040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1967040"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1967040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}