• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

WHMCS and Plesk 12 (502 Bad Gateway)

NicolasP.

Regular Pleskian
Hello.

I need your help.

As I read, when Plesk and WHMCS are in the same server, you may have 502 bad gateway errors when creating an account through WHMCS

Page not Found/Timeout/502 Bad Gateway error creating accounts with Plesk 10+
By default Plesk 10 and above performs a forced restart of apache when an account is created or suspended which causes WHMCS to lose connection to the server, and if your WHMCS is on the same server, you will also lose connection to WHMCS at the same time.

In order to resolve this please refer to the following knowledgebase article for instructions on configuring Plesk to perform a graceful restart instead: http://kb.parallels.com/en/112020

So I activated Apache graceful restart in Plesk and I have no problem yet.

But when I activate nginx in Plesk the 502 bad Gateway problem comes back.

Is there an option to activate Nginx graceful restart in Plesk?
 
a) Check if nignx is enable

# /etc/init.d/nginx status

b) Go to Plesk under domain, "Hosting setting" and try changing "php as" apache to "fast-cgi" or "cgi"

c) try restarting nignx and disable httpd service, sometimes they conflit each other.
 
Thanks hardbrasil but this solution does not work. I already have this settings.

I mean something like this:

Solution
To enable graceful restart, you should add the parameter "restart_apache_gracefully" with a "true" value to the "misc" table of the "psa" database. For that:

  1. Log in to the Plesk database:

    mysql -uadmin -p`cat /etc/psa/.psa.shadow` -Dpsa

  2. Apply the following SQL query:

    mysql> INSERT INTO misc VALUES ('restart_apache_gracefully', 'true');

This makes apache to restart gracefully (not restart, but reload httpd service)
What about nginx? Is there any trick to do it?
 
I had the same problem, but unfortunately I wasn't able to resolve it. Running WHMCS on a Plesk server simply isn't a good idea.

Get yourself a Digital Ocean VPS for $5 and put WHMCS on there -- problem solved.
 
i am running plesk and whmcs on same server,
nignx and apache,
my whmcs is under nignx - Run PHP as "cgi app" - php 5.4

try to disable httpd than restart nignx

service httpd stop
/etc/init.d/nginx restart

if works, you can start httpd after
 
Sorry for opening the thread again, but I solved the WHMCS-Problem with the graceful restart as described in #3.
This does not seem to be working in plesk 12.5 anymore. Adding the datebase-entry results into problems with the configuration files:

Unable to generate the web server configuration file on the host <mail.dedando.de> because of the following errors:

Template_Exception: Can not restart web server:
file: /opt/psa/admin/plib/Service/Driver/Web/Server/Apache.php
line: 104
code: 0

Please resolve the errors in web server configuration templates and generate the file again.
 
IgorG can you confirm that kb.odin.com/en/112020 is not valid for plesk12.5 anymore? Is there a workaround for that?

Or is it just a bug in the configuration-checker extensions?
 
Well, I don't know. For some reason it does not. If I switch it on it messes up the configuration and you have the following error all over the panel:
Code:
New configuration files for the Apache web server were not created due to the errors in configuration templates: Can not restart web server: . Detailed error descriptions were sent to you by email. Please resolve the issues and click here to generate broken configuration files once again or here to generate all configuration files. See the details in Configuration Troubleshooter
If you choose the repair option of all config files the following error comes up:
Code:
Unable to configure the web server: Execution failed. Command: httpdmng Arguments: Array ( [0] => --reconfigure-all ) Details: Execution failed. Command: httpdmng Arguments: Array ( [0] => --reconfigure-domains [1] => autosetuptest1841.de,test123.com,test234.de ) Details: [2015-09-11 13:52:22] ERR [util_exec] proc_close() failed ['/opt/psa/admin/bin/apache_control_adapter' '--restart' '--restart-interval' '0' '--http-port' '80' '--https-port' '443' '--graceful'] with exit code [1] [2015-09-11 13:52:23] ERR [panel] Apache config (14419723400.22649400) generation failed: Template_Exception: Can not restart web server: file: /opt/psa/admin/plib/Service/Driver/Web/Server/Apache.php line: 104 code: 0 plesk sendmail[19863]: sendmail argv = /usr/sbin/sendmail -t -i Can not restart web server:
Freshly installed Plesk 12.5 on Debian Jessie. Are you sure that I haven't found another bug here? I haven't changed anything besides the session_save path in the php ini

If I switch the mysql-config value for graceful restart back to false the reconfiguration of the config works....

I will open up a new thread, because this has nothing to do with WHMCS or bad gateway in the wirst place.
 
I know this thread is very old, but there's still the same problem, not with whmcs, but with normal usage of Plesks Apache + nginx reverse proxy implementation. Each time someone changes something, you have bad gateway for a few seconds. That's not good, especially for e-commerce and other projects which are highly frequented.

On the other hand, I don't think disabling nginx is a solution, because as far as I know a lot of good features implemented in plesk rely on it (HTTP 2.0 and such).

I can't imagine there isn't a solution for a software like plesk which is often used.

How to solve this issue?
 
That issue is most likely caused by concurrent restarts of httpd or non-graceful restarts. You can try to change Apache to graceful restarts with a minimum restart latency window of 20 seconds or more to avoid concurrent restarts of httpd. For details see https://support.plesk.com/hc/en-us/articles/213907285-How-to-enable-Apache-graceful-restart-in-Plesk . But you probably have an entry in some configuration file that is causing a second restart for each restart of the web server. Very often this is the log rotation setting of the modSecurity configuration file, causing a second Apache restart while the first has not completed. This leaves the server unavailable for a few seconds, leading ot the bad gateway error.

Currently, the knowledgebase contains 80 articles on 502 Bad Gateway. See them here: https://support.plesk.com/hc/en-us/search?utf8=✓&query=502
 
Thank you for your answer Peter. I've fixed the problem by commenting out the postrotate commands in the logrotate config of mod_security.

I would post the solution here, if anyone else has the same problem.

But before, I would like to know, if commenting out the reload of apache in the mod_security logrotate config file will cause any problems in my logrotation. Is commenting out the reload really the best solution?

By the way, in my logrotation the command for reloading apache was wrong, because it used /etc/init.d/apache2 to reload apache instead of the correct /sbin/service httpd in my CentOS environment. So the reload didn't actually happen.

Edit: I just got confused by this. I have another reload in the logrotate of httpd:
/sbin/service httpd reload > /dev/null 2>/dev/null || true

So I'm not sure if the problem is solved.

Whats the best way?
 
Last edited:
Back
Top