Websites show 502 Bad Gateway after enabling nginx on a server with Fail2ban


2016-12-12 03:45:12 UTC


2017-08-15 10:49:35 UTC


Was this article helpful?

Have more questions?

Submit a request

Websites show 502 Bad Gateway after enabling nginx on a server with Fail2ban

Applicable to:

  • Plesk 12.5 for Linux
  • Plesk Onyx for Linux
  • Plesk 12.0 for Linux


  1. nginx as a proxy is enabled for a server.
  2. Websites are periodically down with the following error from nginx:

    502 Bad Gateway
  3. The following errors can be found in /var/www/vhosts/system/

    CONFIG_TEXT: [error] 10485#0: *1947668 connect() failed (111: Connection refused) while connecting to upstream, client:, server: , request: "GET / HTTP/1.1", upstream: "", host: ""

    Where is server's IP address.


Fail2Ban blocks server's IP addresses.


  1. In Plesk > Tools & Settings > IP Addresses click Re-read IP button.
  2. Add all server IP addresses to Trusted IP Addresses list in Fail2ban configuration under Tools & Settings > IP Address Banning (Fail2Ban).
  3. If the issue persits, connect to the server using SSH and restart 'iptables' service:
    # service iptables restart
Have more questions? Submit a request


  • 0
    Olosz Andor

    This solution is worked for me (Plesk 17.0.17)

    Thank you! :)

  • 0

    did not help

  • 0
    Pavel Mikhaylov

    Hello iamkingsleyf,

    Could you clarify a few moments, please:

    1. Did the symptoms match entirely to ones you were having? 502 error is quite general and solutions may vary, depending on the additional symptoms.
    2. Does the issue still persist or did you manage to resolve it by other means?

    If the issue is not resolved, I would like to recommend to contact our support:

Please sign in to leave a comment.