Table of Contents
No one likes to see error messages on their screen. In most cases, it creates a feeling of helplessness. You just want to call someone or take a break. The CWP 502 bad gateway error is no different. If you own a server and are facing this error, you can relax. We’ll help you fix it.
The CentOS Web Panel serves PHP pages fast by using PHP-FPM, and PHP-FPM has a knack for throwing bad errors when it’s down.
But what could lead to the unavailability of PHP-FPM and the consequent CWP 502 bad gateway error?
We’ll find out in a coming section. However, before we learn about the causes, what is a 502 bad gateway error?
What is a 502 Bad Gateway Error?
A 502 bad gateway error is a report that indicates a fault in the communication lines between the user and the server. In many cases, it manifests as a blank page which means that the server was unable to fetch and serve the user’s request.
Having learned this, let’s now see what causes the CWP 502 bad gateway error.
What Causes CWP 502 Bad Gateway Error?
Since CWP uses PHP-FPM to serve pages created with the PHP scripting language, it stands to reason that such pages won’t load if PHP-FPM fails.
PHP-FPM, or PHP FastCGI Process Manager, is an application in your server environment that executes PHP codes and helps the server (hardware & OS) generate dynamic content for the user.
PHP-FPM could become unavailable due to a number of reasons. It could be a security attack from malware, a network connectivity issue, a server overload, or hardware failure.
Whatever the cause, the CentOS web panel will return a 502 bad gateway error when it can’t process PHP requests due to PHP-FPM failure. At Da-Manager, our support engineers take definite steps to resolve this problem, and we’ll go through the process in the following section.
How to Fix the 502 Bad Gateway Error
Our support team recently got a call from a customer, and it was about the 502 bad gateway error.
She encountered the error while trying to run some administrative tasks through her CentOS Web Panel. The error denied her access to the admin panel, and it had to be fixed immediately.
The first thing we did to resolve the issue was to ascertain the current status of the server. We used the following command to check the service status.
systemctl status cwp-phpfpm
The command returned an inactive status, meaning we had to restart the service. Successfully restarting the service required knowledge of the source of the error. We checked the log files to locate the user from which the error originated using the following command:
tail /usr/local/cwp/php71/var/log/php-fpm.log
After locating the user, we deleted the following file related to the user error:
/usr/local/cwp/php71/etc/php-fpm.d/users/sam.conf
We deleted the file using the file deletion command:
rm -f /usr/local/cwp/php71/etc/php-fpm.d/users/sam.conf
Having deleted the error log file, we restarted the CentOS Web Panel PHP-FPM service in the command prompt with the following code:
systemctl start cwp-phpfpm
The restart resolved the error, and she could continue her admin activities as usual, delighted that her site was back online.
CWP Web Server Reset – Quick Fix!
In addition to the process outlined above, you can also quickly fix the CWP 502 bad gateway error by restarting the CWP server.
The appropriate command to use in this case will be. …
sh /scripts/restart_cwpsrv
Applying this reset command will restore operational status in most cases, and you can continue with your usual business and administrative activities.
Conclusion
The CentOS Web Panel uses PHP-FPM in serving web pages created with the PHP scripting language. The CWP 502 Bad Gateway Error is usually a consequence of PHP-FPM failure.
In this post, we learned how to quickly fix the CWP 502 bad gateway error. Feel free to use the process outlined here to resolve the issue yourself.
You can also contact our support team for assistance if you face any difficulty or are not technically inclined.
This article was originally published in 14 July 2023. It was most recently updated in September 7, 2023 by