Every WordPress site owner eventually sees one of those messages. “Error establishing a database connection.” “There has been a critical error on this website.” A blank white page. A 500 error. Usually at the worst possible moment.
The messages sound alarming, but most of them have a small set of causes and well-known fixes. Knowing what each error actually means turns panic into a checklist.
Here are the errors I’m called about most often, what causes them and how I fix them. Before you start on any of them, take a backup if you can, and work on a copy if the site is critical.
Error establishing a database connection
What it means
WordPress can’t talk to its database. Without the database, it has no content, settings or users, so it can’t display anything.
Common causes
- Wrong database credentials in wp-config.php, often after a migration or password change.
- The database server is down or overloaded.
- A corrupted database table.
- The hosting account reached a resource limit.
How to fix it
- Check the credentials. Open wp-config.php and confirm DB_NAME, DB_USER, DB_PASSWORD and DB_HOST match what’s set in your hosting panel. DB_HOST isn’t always localhost; some hosts use a specific hostname.
- Test the connection directly. If you have command line access, try logging in with the same details:
If that fails, the problem is the credentials or the database server, not WordPress.
- Check whether the database server is running. On your own server, check the service status. On managed hosting, check the host’s status page or contact support.
- Repair tables if needed. If only some pages fail, or the admin shows a repair message, WordPress has a built-in repair tool. Add this to wp-config.php temporarily:
Then visit /wp-admin/maint/repair.php. Remove the line immediately after, because the repair page doesn’t require login.
- Check server resources. If the error comes and goes under heavy traffic, the database may be running out of connections or memory.
There has been a critical error on this website
What it means
A PHP fatal error occurred. Since WordPress 5.2, instead of a blank page, visitors see this message and the administrator receives an email with details and a recovery mode link.
How to fix it
- Check the admin email for the recovery mode message. It tells you which plugin or theme caused the error and gives you a link to log in with it paused.
- Enable debug logging to see the exact error:
- Read the error in wp-content/debug.log. The file path tells you which plugin or theme is responsible.
- Deactivate the culprit, through recovery mode, WP-CLI, or by renaming its folder over SFTP.
- Fix or replace it. Often an update fixes the issue. If an update caused it, roll back to the previous version while the developer fixes it.
The white screen of death
What it means
A completely blank page with no error message. It’s usually a fatal error with error display turned off, and on older WordPress versions or some configurations, recovery mode didn’t catch it.
How to fix it
The approach is the same as for critical errors: enable debug logging and read the error. If you can’t access the dashboard:
Or rename wp-content/plugins to plugins-off over SFTP, which disables every plugin. If the site comes back, rename the folder back and reactivate plugins one by one.
If plugins aren’t the cause, switch to a default theme by renaming your active theme’s folder. WordPress falls back to a default theme if one is installed.
Also check for memory exhaustion, covered next, which often causes blank pages.
Allowed memory size exhausted
What it means
The error looks like this:
A PHP process tried to use more memory than its limit allows.
How to fix it
- Raise the WordPress memory limit in wp-config.php:
- Raise PHP’s limit if needed, in php.ini or the hosting panel. WordPress can’t exceed the server’s limit.
- Find the real cause. Raising the limit treats the symptom. If one page suddenly needs far more memory than before, something is wrong: a plugin loading huge data sets, a runaway loop or massive autoloaded options. Query Monitor and the error’s file path help identify it.
500 Internal Server Error
What it means
A generic server error. Something went wrong, but the server isn’t saying exactly what.
Common causes
- A corrupted or invalid .htaccess file, on Apache servers.
- PHP fatal errors.
- Incorrect file permissions.
- Server configuration errors.
How to fix it
- Check the server error log. It usually reveals the specific cause.
- Test .htaccess. Rename .htaccess to .htaccess-old. If the site loads, the file was the problem. Go to Settings, then Permalinks, and click Save to generate a fresh one, then re-add any custom rules carefully.
- Check PHP errors with debug logging.
- Check permissions. Files at 644 and directories at 755 are typical. Some servers return 500 errors if files are writable by everyone.
502 Bad Gateway and 504 Gateway Timeout
What it means
The web server, often Nginx, couldn’t get a response from PHP. A 502 means PHP returned an invalid response or wasn’t reachable. A 504 means PHP took too long.
How to fix it
- Check PHP-FPM. It may have crashed, run out of workers or be overloaded. Check its log for messages about reaching max_children.
- Look for slow requests. A slow plugin, external API call or database query can tie up PHP workers. The PHP-FPM slow log helps here.
- Check timeouts. Long operations like imports may need higher timeouts, but it’s usually better to run them through WP-CLI.
- Check server resources. Memory exhaustion can cause PHP-FPM to fail.
If you’re behind a CDN or proxy, the error may come from the proxy failing to reach your server. Check whether the origin server is up.
404 errors on posts and pages
What it means
The homepage works, but individual posts and pages return “Not Found”.
How to fix it
- Resave permalinks. Go to Settings, then Permalinks, and click Save. This rebuilds the rewrite rules and fixes most cases. With WP-CLI:
- Check .htaccess on Apache, which should contain the standard WordPress rewrite rules.
- Check the Nginx config. On Nginx, the location block must include try_files $uri $uri/ /index.php?$args;.
- Check custom post types. If only custom post types return 404s, flush rewrite rules after the post type is registered.
Briefly unavailable for scheduled maintenance
What it means
During updates, WordPress creates a .maintenance file in the site root and shows this message. If an update is interrupted, the file stays, and the site is stuck in maintenance mode.
How to fix it
Delete the .maintenance file from the site root. Then check whether the update that was interrupted completed correctly. Rerun it if needed, and verify core files:
Login redirect loop
What it means
You enter your credentials, the page reloads and you’re back at the login screen.
Common causes
- Site URL and home URL don’t match how you’re accessing the site, such as http versus https or www versus non-www.
- Cookie issues, including a caching layer caching the login page.
- A plugin conflict.
How to fix it
- Clear your browser cookies for the site and try again.
- Check the URLs:
Make sure they match the address you use, including https.
- Exclude login and admin pages from caching.
- Disable plugins to rule out a conflict.
Mixed content warnings after moving to HTTPS
What it means
The site loads over HTTPS, but some images, scripts or styles still load over HTTP. Browsers block or warn about this.
How to fix it
Update URLs in the database with a proper search and replace, after a backup:
Check theme files and custom code for hard-coded http links. The browser console lists every insecure resource.
Upload errors
What it means
Image uploads fail with messages like “The uploaded file exceeds the upload_max_filesize directive” or “Unable to create directory”.
How to fix it
- Raise upload_max_filesize and post_max_size in PHP settings, and client_max_body_size if using Nginx.
- Check that wp-content/uploads exists and is writable by the web server.
- For “HTTP error” in the media library, check PHP memory and image processing library errors in the logs.
Prevention
Most of these errors are preventable:
- Test updates on staging before applying them to the live site.
- Keep backups you can restore quickly.
- Monitor uptime, so you hear about errors before customers do.
- Keep an activity log, so you know what changed.
- Keep PHP and server software supported and updated.
Frequently asked questions
Will I lose my content when these errors happen?
Almost never. Content lives in the database, and most errors prevent WordPress from displaying it rather than deleting it. Keep calm, take a backup and work through the fixes.
Should I restore a backup immediately?
Restoring is a valid fix, especially for critical sites, but you’ll lose changes made since the backup and the cause might return. Where possible, identify the cause, even if you restore first to get back online.
Why does the error only happen sometimes?
Intermittent errors often point to resource limits, like memory, PHP workers or database connections, under traffic spikes. Check logs at the times the errors occurred.
Final thoughts
WordPress errors look frightening, but each one points to a specific area: the database, PHP, the web server, rewrite rules or caching. Read the message, check the logs, isolate the component and apply the matching fix. Combined with staging, backups and monitoring, these errors become short interruptions rather than emergencies.




