• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Error: 502 Bad Gateway nginx (104: Connection reset by peer)

CharKr

New Pleskian
Hi,

this is a fresh Plesk 12 installation on a Dedicated Server, on Debian 6. I haven't installed a License key yet.
When i tried to run MIgration Manager, the loading was taking forever. Also, when i try to enter Webserver Configurations Troubleshooter, i get 502 Bad Gateway nginx error.

In the /var/log/sw-cp-server/error_log i get this error:
Code:
2015/06/17 11:42:47 [error] 3918#0: *52 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: A.B.C.D, server: , request: "GET /modules/configurations-troubleshooter/index.php/index/list HTTP/1.1", upstream: "fastcgi://unix:/var/run/sw-engine.sock:", host: "X.X.X.X:8443", referrer: "https://X.X.X.X:8443/admin/module/list?context=modules"

When i try to insert a Plesk License, i also get this error:
Code:
2015/06/17 10:29:17 [error] 5643#0: *81 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: A.B.C.D., server: , request: "POST /server/
key_upload.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/sw-engine.sock:", host: "X.X.X.X:8443", referrer: "https://X.X.X.X:8443/server/key_upload.php"

I followed this KB article 118757 but no luck. Also, the server resources are at the lowest usage and there is >2 TB disk space available. Can someone help with this matter?
 
Anyone? Any ideas about this?
Plesk is completely inoperable right now with this problem still occuring.
 
You could try the following:

Open /etc/sw-cp-server/config and raise the limits for the fastcgi_buffers - for example:

fastcgi_buffers 32 32k;
fastcgi_buffer_size 64k;

Then save your changes and restart psa:

service psa restart

EDIT: Just saw you tried that already
 
Last edited:
Sorry, was the wrong config - here the right one (/etc/sw-cp-server/config) :)

Code:
worker_processes  2;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"'
                      "'$fastcgi_script_name' '$fastcgi_path_info' '$document_root'";


    sendfile        on;
    reset_timedout_connection on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    #gzip  on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;

    fastcgi_max_temp_file_size 0;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;

    fastcgi_read_timeout 600;
    fastcgi_send_timeout 600;

    client_max_body_size 2048m;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    error_page 497 https://$hostname:$server_port$request_uri;

    include /etc/sw-cp-server/conf.d/*.conf;
}
 
Sorry, was the wrong config - here the right one (/etc/sw-cp-server/config) :)

Code:
worker_processes  2;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"'
                      "'$fastcgi_script_name' '$fastcgi_path_info' '$document_root'";


    sendfile        on;
    reset_timedout_connection on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    #gzip  on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;

    fastcgi_max_temp_file_size 0;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;

    fastcgi_read_timeout 600;
    fastcgi_send_timeout 600;

    client_max_body_size 2048m;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    error_page 497 https://$hostname:$server_port$request_uri;

    include /etc/sw-cp-server/conf.d/*.conf;
}

Looks same just that mine is in a .conf as recommended. will add some that are missing from mine using yours
 
Are you using a nginx-only setup or nginx as proxy for static files in combination with apache?

If you are using nginx as reverse-proxy like me, you could try my config (/etc/nginx/nginx.conf):

Code:
worker_processes auto;
worker_rlimit_nofile 50000;

events {
    worker_connections  1024;
    use epoll;
    multi_accept on;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;

    keepalive_timeout  65;
    keepalive_requests 256;
    reset_timedout_connection on;

    gzip  on;
    gzip_vary on;
    gzip_proxied any;
    gzip_min_length 1000;
    gzip_types text/plain text/xml text/css text/javascript application/x-javascript application/json application/xml application/xml+rss image/png image/gif image/jpeg image/jpg;

    open_file_cache max=50000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;

    client_max_body_size 512m;

    server_tokens off;

    include /etc/nginx/conf.d/*.conf;
}
 
Last edited:
Just for clarification:

/etc/sw-cp-server/config ist the config file for the nginx server that serves the plesk panel
/etc/nginx/nginx.conf ist the config file for the nginx server that serves the customer-vhosts
 
Are you using a nginx-only setup or nginx as proxy for static files in combination with apache?

If you are using nginx as reverse-proxy like me, you could try my config (/etc/nginx/nginx.conf):

Code:
worker_processes auto;
worker_rlimit_nofile 50000;

events {
    worker_connections  1024;
    use epoll;
    multi_accept on;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;

    keepalive_timeout  65;
    keepalive_requests 256;
    reset_timedout_connection on;

    gzip  on;
    gzip_vary on;
    gzip_proxied any;
    gzip_min_length 1000;
    gzip_types text/plain text/xml text/css text/javascript application/x-javascript application/json application/xml application/xml+rss image/png image/gif image/jpeg image/jpg;

    open_file_cache max=50000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;

    client_max_body_size 512m;

    server_tokens off;

    include /etc/nginx/conf.d/*.conf;
}

Hello;

I use Nginx+apache.
also i have 10 domains on the server mostly wordpress.
The server is a 4GB ram server, i have worker_processs to 4 and worker_connections to 4096.
 
Here is the story;

After setting up everything it was working fine for 9 days then later all sites went offline including plesk panel, i change the panel dns to DO and it started to work. if i restart the server it works for few hours and start going offline one by one (right now one is down and consuming more RAM). so i checked the log to see this;

Code:
1563#0: *36251 upstream timed out (110: Connection timed out) while reading response header from upstream

then after following this https://kb.plesk.com/en/120210 it worked for few hours and went offline again. the log showed the following

Code:
556#0: *31779 recv() failed (104: Connection reset by peer) while reading response header from upstream                nginx error
2016-03-09 13:43:45    Error    208.43.68.59        1556#0: *31857 recv() failed (104: Connection reset by peer) while reading response header from upstream                nginx error
2016-03-09 13:43:46    Error    67.228.213.178        1556#0: *31859 recv() failed (104: Connection reset by peer) while reading response header from upstream                nginx error
2016-03-09 13:44:55    Error    66.249.65.20        1556#0: *31984 recv() failed (104: Connection reset by peer) while reading response header from upstream                nginx error
2016-03-09 13:45:08    Error    71.75.134.51        1556#0: *32002 recv() failed (104: Connection reset by peer) while reading response header from upstream                nginx error
2016-03-09 13:45:20    Error    82.145.219.59        1556#0: *32023 recv() failed (104: Connection reset by peer) while reading response header from upstream                nginx error
2016-03-09 13:47:22    Error    82.145.209.56        1556#0: *32175 recv() failed (104: Connection reset by peer) while reading response header from upstream

i followed the tutorial again https://kb.plesk.com/en/120210 and it came back, now its going offline starting with one domain
 
Sounds like you have a problem with your resources (not enough).

If it is a problem with your resources, you should consider to change / optimize your setup, for example:

- Switch from apache worker to event
- Disable all unused apache-modules
- Use the highest possible PHP-Version (Current Wordpress runs fine on PHP 7.x)
- Execute PHP via php-fpm and pm=ondemand (default in Plesk)

If you are not sure about your resources, you should monitor your server / resources with
tools like top or htop to see what is going on. You could also connect your server to new relic or something of that sort.
 
Sounds like you have a problem with your resources (not enough).

If it is a problem with your resources, you should consider to change / optimize your setup, for example:

- Switch from apache worker to event
- Disable all unused apache-modules
- Use the highest possible PHP-Version (Current Wordpress runs fine on PHP 7.x)
- Execute PHP via php-fpm and pm=ondemand (default in Plesk)

If you are not sure about your resources, you should monitor your server / resources with
tools like top or htop to see what is going on. You could also connect your server to new relic or something of that sort.

I have enough resources, am using a 4GB RAM and 80GB SSD drive. i will try the other suggestions....

oh just received alert the rest are down
 
Are you sure? How is PHP being executed currently? mod_php, fcgid oder php-fpm?

Apache Worker + fcgid can consume very much resources.
 
Are you sure? How is PHP being executed currently? mod_php, fcgid oder php-fpm?

Apache Worker + fcgid can consume very much resources.

Code:
2016-03-09 23:41:57    Error    66.249.90.9    4943#0: *47753 recv() failed (104: Connection reset by peer) while reading response header from upstream

php-fpm (php7)

I issues is new to me, i was using nginx+hhvm and nothing like this for over 2 months
 
My Nginx Conf

Code:
#user  nginx;
worker_processes  4;
worker_rlimit_nofile 50000;

#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
    use epoll;
    multi_accept on;
}


http {

    fastcgi_buffers 8 128k;
    fastcgi_buffer_size 256k;
    fastcgi_read_timeout 600;
    fastcgi_send_timeout 600;
    proxy_connect_timeout       600;
    proxy_send_timeout          600;
    proxy_read_timeout          600;
    send_timeout                600;
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;

    keepalive_timeout  65;
    keepalive_requests 256;
    reset_timedout_connection on;

    gzip         on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_proxied any;
    gzip_comp_level 6;
    #gzip_min_length  1000;
    gzip_types   text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
    gzip_vary    on;
    server_tokens off;

    open_file_cache max=50000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;

    client_max_body_size 512m;

    include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;
 
Just for clarification - you are using apache worker + php-fpm to handle php-files and nginx as reverse proxy for static files, right?
 
Is there something interesting in the other logs? (messages / syslog etc.)

Coupondig.com

Code:
2016-03-02 22:46:43    Error    45.32.193.30    AH01276: Cannot serve directory /var/www/vhosts/coupondig.com/httpdocs/wp-content/cache/: No matching DirectoryIndex (at_domains_index.html,index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm,index.shtml,index.cfm) found, and server-generated directory index forbidden by Options directive    Apache error
2016-03-07 23:53:11    Error    180.76.15.31    2181#0: *1560213 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-07 23:54:40    Error    180.76.15.10    2181#0: *1560364 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-08 06:14:27    Error    180.76.15.8    1557#0: *18982 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-08 06:47:46    Error    202.46.51.209    1557#0: *21226 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-08 06:55:22    Error    180.76.15.161    1557#0: *21701 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-08 06:56:53    Error    180.76.15.24    1557#0: *21816 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-08 07:21:06    Error    185.10.107.69    1557#0: *23492 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-08 07:24:16    Error    180.76.15.160    1557#0: *23747 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-08 18:53:36    Error    180.76.15.136    1550#0: *80545 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-08 18:55:10    Error    180.76.15.26    1550#0: *80674 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-08 21:53:08    Error    180.76.15.27    1550#0: *94674 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-08 21:54:43    Error    180.76.15.5    1550#0: *94817 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-09 02:53:15    Error    180.76.15.6    1563#0: *21047 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-09 02:54:49    Error    180.76.15.5    1563#0: *21165 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-09 03:53:06    Error    180.76.15.150    1563#0: *24956 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-09 03:54:38    Error    180.76.15.5    1563#0: *25069 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-09 04:41:56    Error    144.76.175.75    1563#0: *28492 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-09 04:41:58    Error    144.76.175.75    1563#0: *28494 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-09 04:47:31    Error    104.236.193.199    1563#0: *28877 upstream timed out (110: Connection timed out) while reading response header from upstream    nginx error
2016-03-09 07:22:40    Error    66.249.65.75    1556#0: *9 connect() failed (111: Connection refused) while connecting to upstream    nginx error
2016-03-09 12:28:24    Error    100.1.180.140    AH01070: Error parsing script headers, referer: https://coupondig.com/search-page/deal/412/    Apache error
 
Back
Top