How to Fix 502, 503, and 504 Errors on a Website: Hosting Troubleshooting Guide
HTTP errorshosting troubleshootingWordPress errorsserver errorswebsite downtimePHP

How to Fix 502, 503, and 504 Errors on a Website: Hosting Troubleshooting Guide

HHostingFreeWebsites Editorial Team
2026-11-10
7 min read

Learn what 502, 503, and 504 errors mean, how to troubleshoot hosting and WordPress causes, and what to track when outages recur.

502, 503, and 504 errors all indicate that a request could not be completed, but they point to different stages of the connection failing. This guide explains what each status means, how to separate hosting, proxy, DNS, PHP, and application problems, and which checks to record so recurring outages become easier to diagnose.

Overview

These errors usually involve more than one component: a browser or search crawler, a DNS service, a reverse proxy or CDN, the web server, PHP workers, a database, and the website application. The visible error page tells you that something failed, but it does not always identify which component is responsible.

ErrorWhat it usually meansCommon causes
502 Bad GatewayA proxy or gateway received an invalid response from an upstream server.Stopped web server, failed PHP-FPM process, incorrect proxy configuration, incompatible application response, or a DNS record pointing to the wrong service.
503 Service UnavailableThe server is temporarily unable to handle the request.Hosting account limits, maintenance, overloaded CPU or memory, exhausted PHP workers, disabled application, or a server deliberately placed in maintenance mode.
504 Gateway TimeoutA gateway or proxy waited too long for an upstream response.Slow database query, long-running PHP task, overloaded origin server, blocked external request, or a timeout that is shorter than the application task requires.

The distinction is a starting point rather than a diagnosis. A busy shared hosting account may produce 503 responses at one moment and 504 responses at another. A configuration change can turn an application problem into a 502 after a proxy is unable to understand the new response. Record the exact code, time, URL, and whether the problem affects one page or the entire site before changing settings.

For WordPress sites, temporarily disabling a recently changed plugin or theme can help isolate an application failure, but make a backup first and avoid making several changes at once. If you cannot access the dashboard, use the hosting file manager or SFTP to rename the relevant plugin directory, then restore the original name after testing.

What to track

Create a small incident log for every occurrence. The following details are more useful to hosting support than a message saying that “the website is down.”

  • Time and timezone: Note when the error began, when it ended, and whether it is still occurring.
  • Exact response: Record the status code, browser message, branded proxy page, and any request or Ray ID shown on the page.
  • Scope: Test the homepage, an ordinary post or page, the login area, a static file, and an API or checkout route if relevant. Note whether the error affects all visitors or only one path.
  • Recent changes: List plugin, theme, CMS, PHP, DNS, SSL, server, caching, firewall, and deployment changes made shortly before the incident.
  • Resource usage: Check CPU, memory, entry processes, PHP workers, bandwidth, storage, and inodes in the hosting panel. Labels differ between cPanel, custom dashboards, managed WordPress hosting, and VPS platforms.
  • Logs: Review web-server error logs, PHP logs, application logs, and proxy or CDN logs. Common locations include a hosting panel's Metrics or Logs area, an account-level error_log file, or a server log directory on a VPS. Paths and access permissions vary by provider.
  • External dependencies: Check whether the application is waiting for an external API, payment service, database, object storage system, or remote DNS service.

Also confirm that DNS points to the intended host. A DNS error more commonly causes a lookup or connection failure, but a stale A record, incorrect AAAA record, or proxy connected to the wrong origin can result in a gateway error. Use a DNS checker or query the record from more than one network, then compare the result with your hosting provider's required records. For a broader walkthrough, see How to Connect a Domain to Web Hosting.

Keep backups before changing PHP versions, web-server rules, plugins, or database settings. The Website Backup and Restore Guide explains how to make recovery a repeatable process rather than an improvised step during an outage.

Cadence and checkpoints

Use a short workflow during an incident, then review the pattern monthly or quarterly even when the site appears healthy.

During the first five minutes

  1. Open the site from a separate network or device to rule out a local cache, browser extension, or office firewall.
  2. Test several URLs and note the status code for each. Do not repeatedly refresh a failing checkout or form if it could create duplicate actions.
  3. Check the hosting dashboard for maintenance notices, suspended services, resource alerts, and recent deployments.
  4. Pause any rollout, bulk import, backup job, or scheduled task that may be consuming resources, if doing so is safe.
  5. Capture the time, error page, affected URL, and relevant request identifier before clearing caches.

During the next 15 to 30 minutes

  1. Compare web-server, PHP, application, and proxy logs at the incident time.
  2. Check whether PHP workers, memory, CPU, database connections, or process limits were exhausted.
  3. Review the last code, plugin, theme, PHP, DNS, SSL, or configuration change. Roll back only a change you can identify and restore safely.
  4. Test with application caching and CDN caching considered separately. Purging a cache may reveal a problem, but it will not repair an overloaded origin server.
  5. Contact hosting support with evidence if the origin is unreachable, limits are being reached, or logs show a server-side failure.

Monthly or quarterly review

Review your incident log for repeated times, URLs, status codes, traffic patterns, and resource peaks. Compare those findings with uptime monitoring and hosting usage reports. The guide to monitoring CPU, RAM, bandwidth, and inodes can help turn a vague “slow hosting” concern into a measurable capacity question.

Check that backups complete, monitoring alerts still reach the right person, the CMS and plugins remain compatible with the selected PHP branch, and test or staging changes are not being made directly on production. Review how to choose a PHP version before changing the runtime.

How to interpret changes

A single error immediately after a deployment points first to the changed code, configuration, runtime, or dependency. Repeated errors during traffic peaks point more strongly toward resource limits, database contention, worker exhaustion, or a slow operation. Errors affecting only one dynamic route suggest an application or database issue; errors affecting static files and every page suggest a web server, network, DNS, or hosting-level problem.

Compare the origin response with the public response when a CDN or reverse proxy is in use. If the origin works directly but the public hostname returns 502 or 504, inspect proxy origin settings, TLS mode, firewall rules, health checks, and timeout values. If both fail, focus on the hosting server and application first.

Timeout settings should be changed cautiously. Increasing a proxy or PHP timeout may prevent a legitimate long task from failing, but it can also allow too many expensive requests to remain active. First find out why the request is slow. Optimize a database query, reduce an import batch, move a scheduled job, or use a background process where appropriate. On shared hosting, some limits cannot be changed by the account owner, so ask the provider which limit was reached rather than guessing.

For WordPress, compare the timestamp with scheduled tasks, search indexing, image processing, backups, plugin updates, and traffic campaigns. Disable one suspected extension at a time and test after each change. If a clean plugin test does not help, inspect PHP compatibility, database health, theme code, and hosting resources rather than continuing to deactivate unrelated plugins.

If the same failure returns after reasonable optimization, compare the account's capacity and support access with alternative free and cheap shared hosting options. A migration is not the first response to every error, but recurring resource or infrastructure problems may justify a planned move. Record files, databases, DNS, email, SSL, redirects, and testing steps before migrating; the website migration guide covers that checklist.

When to revisit

Return to this guide whenever a 502, 503, or 504 alert appears, after a major deployment, during a traffic spike, or when a hosting provider changes its control panel, PHP branches, proxy arrangement, or log locations. Revisit the troubleshooting checklist monthly for a busy business site and at least quarterly for a smaller site. The goal is not to change working settings on a schedule; it is to confirm that monitoring, backups, logs, and escalation details still work.

Keep a current incident template with these fields: date and timezone, status code, affected URLs, networks tested, recent changes, resource readings, log excerpts, actions taken, recovery time, and support ticket number. When contacting a host, include the domain, exact timestamps, request IDs, affected paths, whether the origin or proxy was tested, and what has already been ruled out. Avoid sending passwords or private customer data.

Finally, verify recovery from more than one network, test important forms or transactions without creating duplicate orders, confirm that scheduled jobs resumed, and watch the site for a period after the error disappears. Update the incident log with the confirmed cause or the best available explanation. That record turns the next outage from a search for clues into a short, repeatable response.

Related Topics

#HTTP errors#hosting troubleshooting#WordPress errors#server errors#website downtime#PHP
H

HostingFreeWebsites Editorial Team

Senior SEO Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.