Fix WordPress Connection Errors and 50x Faults
Learn how to troubleshoot and fix common WordPress connection errors and 50x server faults on an Ubuntu 24.04 LTS cloud VPS or dedicated server.
Running a WordPress website on a cloud VPS or dedicated server gives you total control over your environment. However, when things go wrong, you also carry the responsibility of diagnosing and fixing the issue. Connection errors and 50x server faults can bring your business to a halt, frustrating visitors and potentially hurting your search engine rankings.
Whether you are managing a high-traffic e-commerce store or a growing content blog, knowing how to systematically troubleshoot these errors is an essential skill. In this guide, we will walk through a step-by-step diagnostic process to identify the root cause of common WordPress connection issues and 50x server faults using an Ubuntu 24.04 LTS server environment.
1. Check the Nginx or Apache Error Logs
When a 50x error occurs, your web server is encountering an unexpected condition that prevents it from fulfilling the request. Instead of guessing the cause, your first step should always be inspecting the error logs. If you are using Nginx with PHP-FPM on Ubuntu 24.04 LTS, the logs will point you directly to the problem.
Log in to your server via SSH and examine the Nginx error log using the following command:
sudo tail -n 50 /var/log/nginx/error.log
This command displays the last 50 lines of the Nginx error log, helping you spot recent timeouts, configuration syntax errors, or permission denied issues.
If your site runs on Apache instead, you can check its error log with:
sudo tail -n 50 /var/log/apache2/error.log
This command displays the last 50 lines of the Apache error log.
Look for fatal PHP errors, missing files, or upstream connection failures. Fixing the specific error referenced in these logs often resolves the 50x fault immediately.
2. Inspect PHP-FPM Service and Socket Status
A very common cause of a 502 Bad Gateway error in WordPress is a failure in the PHP-FPM (FastCGI Process Manager) service. If Nginx cannot communicate with the PHP socket, it cannot process your PHP scripts and throws a server error.
First, verify that the PHP-FPM service is running on your Ubuntu 24.04 LTS server:
sudo systemctl status php8.3-fpm
This command checks the current status of the PHP 8.3 FPM service. Adjust the PHP version number if your server runs a different release, such as PHP 8.1 or 8.2.
If the service is stopped, restart it with:
sudo systemctl restart php8.3-fpm
This command restarts the PHP 8.3 FPM service to clear hung processes and reload configurations.
If PHP-FPM fails to start, check the specific PHP pool error logs located in /var/log/php8.3-fpm.log to identify syntax errors in your configuration files or resource exhaustion issues.
3. Diagnose Database Connection Failures
When visitors see "Error establishing a database connection," your WordPress site cannot communicate with your MySQL or MariaDB database server. This can be caused by incorrect credentials in your wp-config.php file, a corrupted database, or an unresponsive database service.
Start by checking if the MySQL or MariaDB service is active on your server:
sudo systemctl status mysql
This command displays the current operational status of the MySQL service.
If the service is down, attempt to start it:
sudo systemctl start mysql
This command starts the MySQL service.
Next, verify that your database credentials in your WordPress root directory are correct. Open your configuration file:
sudo nano /var/www/html/wp-config.php
This command opens the WordPress configuration file in the nano text editor.
Check the following constants to ensure they match your database username, password, and host:
DB_NAMEDB_USERDB_PASSWORDDB_HOST
If these details are correct and the service is running, test connecting to the database via the command line:
mysql -u your_db_user -p
This command attempts to open an interactive MySQL shell using the specified database user.
Enter your password when prompted. If the login fails, you may need to reset the database user permissions or update the password.
4. Investigate Server Resource Exhaustion (RAM and CPU)
A sudden spike in traffic or a resource-heavy plugin can exhaust your server's RAM and CPU, leading to 504 Gateway Timeouts or general 500 errors. When the kernel runs out of memory, the Linux Out-Of-Memory (OOM) killer may terminate critical processes like MySQL or PHP-FPM.
Use the top or htop utility to monitor real-time resource utilization on your Ubuntu 24.04 LTS server:
htop
This command launches the htop interactive process viewer to check CPU and memory usage.
Pay close attention to the Memory and Swap bars at the top. If memory usage is constantly at 100%, your server may require an upgrade, or you need to optimize your PHP and MySQL memory limits.
You can also check the system log for recent OOM killer events:
sudo grep -i oom /var/log/syslog
This command searches the system log for references to Out-Of-Memory killer events.
If you see entries indicating that MySQL or PHP processes were killed due to memory limits, consider lowering your PHP-FPM pm.max_children setting or upgrading your cloud VPS plan to a higher tier with more RAM.
5. Debug Faulty Plugins and Themes
If your server resources are healthy and logs point to PHP application errors, a newly updated plugin or theme might be causing a fatal error (HTTP 500). If you cannot access the WordPress dashboard, you can disable plugins and themes directly via SSH.
Navigate to your WordPress plugin directory:
cd /var/www/html/wp-content/plugins
This command changes the current working directory to the WordPress plugins folder.
Temporarily rename the plugins folder to disable all plugins at once:
sudo mv plugins plugins-disabled
This command renames the plugins directory, which deactivates all active WordPress plugins simultaneously.
Check if your website loads. If it does, rename the folder back to plugins, then rename individual plugin subdirectories one by one to isolate the culprit. You can follow a similar diagnostic approach for themes inside the /var/www/html/wp-content/themes directory.
6. Review File Permissions and Ownership
Incorrect file permissions are a frequent source of "Forbidden" or internal server errors on Linux-based web servers. Nginx or Apache must have the correct read and write permissions to process your files.
On Ubuntu, your web root files should typically be owned by your system's web user and group (often www-data). Run the following commands to correct ownership and directory permissions for your WordPress installation:
sudo chown -R www-data:www-data /var/www/html
This command recursively changes the owner and group of all files in the web root to the web server user.
sudo find /var/www/html -type d -exec chmod 755 {} \;
This command sets the correct permissions (755) for all directories within the web root.
sudo find /var/www/html -type f -exec chmod 644 {} \;
This command sets the correct permissions (644) for all files within the web root.
Proper server hygiene and routine monitoring are the best defenses against unexpected downtime. Always back up your database and configuration files before making major changes to your server environment.
Conclusion
Troubleshooting connection errors and 50x server faults on WordPress requires a calm, methodical approach. By systematically checking your web server error logs, verifying PHP-FPM and database services, monitoring system resources, and isolating faulty plugins, you can resolve most issues quickly.
Managing your own cloud VPS or dedicated server gives you the power to inspect every layer of your stack. Keep your software updated, monitor your logs regularly, and use the command-line tools available in Ubuntu 24.04 LTS to keep your WordPress applications running smoothly and securely.
Try it on your own server
Follow along on a Cloud VPS with full root access, or read the step-by-step knowledge base guides.