Question

Getting Nginx fpm.sock error

My Droplet:

8 GB RAM 80 GB Space 4 Core CUP $80 Monthly Server : Nginx Database : MySQL I installed one click LEMP from the Admin panel and run a Wordpress site.

I’m getting errors like this everyday:

2015/06/06 14:04:27 [error] 12948#0: *19545859 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 123.201.237.162, server: www.mysite.com, request: "GET /telugu/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/"
2015/06/06 14:04:27 [error] 12946#0: *19546893 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 49.206.217.71, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/large.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/telugu/2015-telugu/"
2015/06/06 14:04:27 [error] 12948#0: *19546925 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 49.206.217.71, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/telugu/2015-telugu/"
2015/06/06 14:04:30 [error] 12945#0: *19538751 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 49.207.96.9, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/english/page/4/?display=tube&filtre=views"
2015/06/06 14:04:30 [error] 12945#0: *19547134 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 92.96.146.25, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/large.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/malayalam/"
2015/06/06 14:04:30 [error] 12945#0: *19547134 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 92.96.146.25, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/malayalam/"
2015/06/06 14:04:30 [error] 12945#0: *19547134 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 92.96.146.25, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/malayalam/"
2015/06/06 14:04:30 [error] 12946#0: *19547510 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 31.49.58.222, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page25/"
2015/06/06 14:04:30 [error] 12946#0: *19547510 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 31.49.58.222, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page25/"
2015/06/06 14:04:30 [error] 12946#0: *19542884 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 80.184.44.114, server: www.mysite.com, request: "GET /hindi/2015-hindi-hindi/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/malayalam/"
2015/06/06 14:04:30 [error] 12946#0: *19547502 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 210.212.190.49, server: www.mysite.com, request: "GET /avengers-2-age-ultron-movie-online-watch-hollywood-full-length-film-english-movie/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "https://www.google.co.in/"
2015/06/06 14:04:30 [error] 12945#0: *19547522 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 31.49.58.222, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/large.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page25/"
2015/06/06 14:04:30 [error] 12945#0: *19547526 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 121.54.54.139, server: www.mysite.com, request: "GET /fast-furious-7-2015-full-movie-online-watch-english-full-length-film-hollywood-movie/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com"
2015/06/06 14:04:34 [error] 12945#0: *19545368 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 150.107.188.223, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page36/"
2015/06/06 14:04:34 [error] 12947#0: *19547801 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 117.200.243.224, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/"
2015/06/06 14:04:46 [error] 12945#0: *19546882 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 175.139.172.22, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/large.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page48/"
2015/06/06 14:04:46 [error] 12946#0: *19548721 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 87.210.127.11, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page25/"
2015/06/06 14:04:46 [error] 12946#0: *19548722 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 87.210.127.11, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page25/"
2015/06/06 14:04:48 [error] 12946#0: *19548902 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 23.236.125.199, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page78/"
2015/06/06 14:04:49 [error] 12947#0: *19548261 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 49.248.136.243, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page25/"
2015/06/06 14:04:49 [error] 12947#0: *19548263 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 49.248.136.243, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page25/"
2015/06/06 14:04:49 [error] 12946#0: *19543775 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 27.4.216.210, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page2015/"
2015/06/06 14:04:49 [error] 12945#0: *19547719 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 5.198.226.18, server: www.mysite.com, request: "GET /hindi/2015-hindi-hindi/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/"
2015/06/06 14:05:02 [error] 12948#0: *19549927 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 116.203.72.57, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/?s=PK"
2015/06/06 14:05:03 [error] 12946#0: *19549568 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 79.181.130.103, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page85/"
2015/06/06 14:05:03 [error] 12946#0: *19549981 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 49.205.70.77, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page90/"
2015/06/06 14:05:03 [error] 12948#0: *19549963 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 79.181.130.103, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page45/"
2015/06/06 14:05:10 [error] 12945#0: *19550444 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 182.68.27.181, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page25/"
2015/06/06 14:05:10 [error] 12948#0: *19550032 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 103.15.63.118, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/"
2015/06/06 14:05:10 [error] 12945#0: *19550447 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 37.231.171.106, server: www.mysite.com, request: "GET /telugu/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://www.google.com.kw/"
2015/06/06 14:05:10 [error] 12948#0: *19550026 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 103.15.63.118, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/large.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/"
2015/06/06 14:05:10 [error] 12948#0: *19549991 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 190.33.66.70, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page36/"
2015/06/06 14:05:10 [error] 12948#0: *19549993 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 190.33.66.70, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page83/"
2015/06/06 14:14:08 [error] 12946#0: *19587787 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 117.221.122.149, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/large.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/"
2015/06/06 14:14:08 [error] 12946#0: *19587789 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 117.221.122.149, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/"
2015/06/06 14:14:08 [error] 12946#0: *19587788 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 117.221.122.149, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/colors.php?color=00a5ae&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/"
2015/06/06 14:14:09 [error] 12947#0: *19587610 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 116.203.79.137, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page57/"
2015/06/06 14:14:10 [error] 12948#0: *19588323 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 61.246.208.190, server: www.mysite.com, request: "GET /hindi/feed/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com"
2015/06/06 14:14:10 [error] 12946#0: *19581572 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 182.186.47.172, server: www.mysite.com, request: "GET /wp-content/themes/novavideo/css/horizontal.php?responsive=yes&ver=4.1.1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/page69/"
2015/06/06 14:49:18 [error] 12948#0: *19721366 FastCGI sent in stderr: "PHP message: PHP Warning:  session_start(): The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in /var/www/mysite.com/html/wp-content/plugins/wsecure/wsecure-authentication.php on line 15" while reading response header from upstream, client: 173.88.208.211, server: www.mysite.com, request: "GET /page69/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com"
2015/06/06 14:49:18 [error] 12948#0: *19721366 FastCGI sent in stderr: "PHP message: PHP Warning:  Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0
PHP mess" while reading upstream, client: 173.88.208.211, server: www.mysite.com, request: "GET /page874/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com"
2015/06/06 14:49:18 [error] 12948#0: *19721366 FastCGI sent in stderr: "age: PHP Warning:  Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php5) in Unknown on line 0" while reading upstream, client: 173.88.208.211, server: www.mysite.com, request: "GET /page89/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com"
2015/06/07 01:03:26 [error] 12948#0: *20918559 FastCGI sent in stderr: "PHP message: PHP Warning:  session_start(): The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in /var/www/mysite.com/html/wp-content/plugins/wsecure/wsecure-authentication.php on line 15" while reading response header from upstream, client: 203.106.152.30, server: www.mysite.com, request: "GET /page27/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "https://www.google.com.my/"
2015/06/07 01:03:26 [error] 12948#0: *20918559 FastCGI sent in stderr: "PHP message: PHP Warning:  Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0
PHP message: PHP Warning:  Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php5) in Unknown on line 0" while reading upstream, client: 203.106.152.30, server: www.mysite.com, request: "GET /page47/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "https://www.google.com.my/"
2015/06/07 01:23:38 [error] 12946#0: *20971048 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 178.63.13.15, server: www.mysite.com, request: "GET /genre/page/15/?display=extract&filtre=date HTTP/1.0", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com"
2015/06/07 01:23:38 [error] 12946#0: *20969415 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 221.154.17.6, server: www.mysite.com, request: "GET /malayalam/page/2/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/english/"
2015/06/07 01:23:39 [crit] 12946#0: *20970895 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 108.184.27.146, server: www.mysite.com, request: "GET /dil-dhadakne-2015-full-movie-online-watch-hindi-full-length-film/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/hindi/"
2015/06/07 01:24:07 [error] 12945#0: *20970770 directory index of "/var/www/mysite.com/html/wp-content/uploads/2015/02/" is forbidden, client: 178.152.60.151, server: www.mysite.com, request: "GET /wp-content/uploads/2015/02/ HTTP/1.1", host: "mysite.com", referrer: "http://mysite.com/wp-content/uploads/2015/02/official-1233.jpg"

MY Virtual Host File is:

server {
        listen 80;
        listen [::]:80;

        root /var/www/mysite.com/html;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name www.mysite.com mysite.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?q=$request_uri;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }
        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_index index.php;
                include fastcgi_params;
        }

        # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
        #location /RequestDenied {
        #       proxy_pass http://127.0.0.1:8080;
        #}

        #error_page 404 /404.html;
        # redirect server error pages to the static page /50x.html
        #
        #error_page 500 502 503 504 /50x.html;
        #location = /50x.html {
        #       root /usr/share/nginx/html;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #
        #       # With php5-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#       listen 8000;
#       listen somename:8080;
#       server_name somename alias another.alias;
#       root html;
#       index index.html index.htm;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }
#}


# HTTPS server
#
#server {
#       listen 443;
#       server_name localhost;
#
#       root html;
#       index index.html index.htm;
#
#       ssl on;
#       ssl_certificate cert.pem;
#       ssl_certificate_key cert.key;
#
#       ssl_session_timeout 5m;
#       ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
#       ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
#       ssl_prefer_server_ciphers on;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }
#}

and my Nginx Config file is:

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
        worker_connections 1024;
        multi_accept on;
}

http {

        ##
        # Basic Settings
        ##
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        keepalive_requests 100000;

        client_body_buffer_size 10K;
        client_header_buffer_size 1k;
        client_max_body_size 8m;
        large_client_header_buffers  4 32k;
        client_body_timeout 12;
        client_header_timeout 12;
        send_timeout 10;

        types_hash_max_size 2048;
        # server_tokens off;
        server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_static on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##

        #include /etc/nginx/naxsi_core.rules;

        ##
        # nginx-passenger config
        ##
        # Uncomment it if you installed nginx-passenger
        ##

        #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
        # Virtual Host Configs
        ##
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

My fastcgi_param File is:

fastcgi_param   QUERY_STRING            $query_string;
fastcgi_param   REQUEST_METHOD          $request_method;
fastcgi_param   CONTENT_TYPE            $content_type;
fastcgi_param   CONTENT_LENGTH          $content_length;

fastcgi_param   SCRIPT_FILENAME         $request_filename;
fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;
fastcgi_param   REQUEST_URI             $request_uri;
fastcgi_param   DOCUMENT_URI            $document_uri;
fastcgi_param   DOCUMENT_ROOT           $document_root;
fastcgi_param   SERVER_PROTOCOL         $server_protocol;

fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;

fastcgi_param   REMOTE_ADDR             $remote_addr;
fastcgi_param   REMOTE_PORT             $remote_port;
fastcgi_param   SERVER_ADDR             $server_addr;
fastcgi_param   SERVER_PORT             $server_port;
fastcgi_param   SERVER_NAME             $server_name;

fastcgi_param   HTTPS                   $https if_not_empty;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param   REDIRECT_STATUS         200;

I’m a newbie to Nginx and I asked several time this problem to support and they were unable to find out a solution for this.

I have two problem with my this site.

  1. I want to rid of from my the aforesaid errors. How can I solve this issue?

  2. I want to open my site as “www.mysite.com”, now its opening as http://mysite.com instead of http://www.mysite.com. Domain AAA records are correct. I think there is a bad config in my ngnix.conf. Plz suggest me the correct configuration for this.

  3. I think my Nginx.conf file is not optimized in a better way. I’m getting around 10k- 15k traffic each day. some time my site is opening very slowly. How can I speed up my site?

Thanks in Advance for your valuable suggestion.

NB: Sorry for the Bad English. Its not my native Language.

Subscribe
Share

Hi DO Team

I am facing the same issue that connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream.90% of my error log file is due to this error.I want to fix this.Kindly help. Mail ID:- rishipdp@gmail.com

@eldin please help me to fix "upstream: “fastcgi://unix:/var/run/php5-fpm.sock”. Pplease email me kusnendarebid(at)gmail(.)com. thanks


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

@bijuoos I had sent you a mail

@bijuoosmail

Question 2:

nano /etc/nginx/nginx.conf

Edit this for a faster nginx

worker_processes  4;

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

Question 1:

To use www.domain.com you need to change your DNS, add a A Record with name www

Now we need to configure Nginx nano /etc/nginx/sites-available/default

 server_name your_domain www.your_domain;

Don´t forget to restart nginx service nginx restart

Question 3: How about you remove your Browser Cache ? This works most of the time

@bijuoosmail sorry for the delay.

Backup your old Configuration

sudo cp -r /etc/php5 /etc/pgp5_old

Remove your old Nginx and PHP5 installation

Reinstall Nginx and PHP

Now we are going to configure Nginx and PHP right

touch /etc/nginx/sites-available/default
nano /etc/nginx/sites-available/default

Paste this (right click) edit root and server name. Save it (CTRL X)

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.php index.htm;

    server_name your_domain;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
        autoindex on;
    }

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #   deny all;
    #}
}

# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#   listen 80;
#   listen [::]:80;
#
#   server_name example.com;
#
#   root /var/www/example.com;
#   index index.html;
#
#   location / {
#       try_files $uri $uri/ =404;
#   }
#}

Restart your Server service nginx restart

PS: If it works, please show me some love and click the hearth

Welcome to DigitalOcean.

If you can´t understand English well, I could do it for you. Just ask and I provide my email address. If you don´t want that I could post a tutorial for you.

Just reply what you want

Hello I am getting errors 504 and 502 for my nginx server with wordpress websites. Please give me proper solutions for this two errors, because approx 2hr i am getting 504 bad gatway error.

Hi,

I upgraded my ubuntu from 14 to 16.04 as in this article :

https://www.digitalocean.com/community/tutorials/how-to-upgrade-to-ubuntu-16-04-lts

After that, nginx is not working properly : connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) for all access.

I noticed that /var/run/php5-fpm.sock does not exist. I changed the default in sites-available to point to /var/run/php7-fpm.sock (which exists) instead.

Restarted the service but still get the same error.

Please help!

This solved my problem: service php5-fpm restart

Hello @eldin

I have read the thread and others too. somehow I mixed it up I suppose and can’t make it work again.

I am receiving bunch of these;

2016/04/13 16:53:44 [crit] 916#0: *530 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 185.103.252.172, server: ozgurahsap.com, request: “POST /xmlrpc.php HTTP/1.0”, upstream: “fastcgi://unix:/var/run/php5-fpm.sock:”, host: “95.85.34.33”

Could you help me out?

Hello @bijuoos @oriolcaldero @joannalee0910 @akehat @kusnendarwebid5,

OMG I totally forgot answer this question, sorry.

Here you go:

Before you start Snapshoot your Droplet

Paste this (at the end of the file) to /etc/sysctl.conf (using nano /etc/sysctl.conf) and save it (this change not only fixes your error it makes your System much better),

### IMPROVE SYSTEM MEMORY MANAGEMENT ###

# Increase size of file handles and inode cache
fs.file-max = 2097152

# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2

### GENERAL NETWORK SECURITY OPTIONS ###

# Number of times SYNACKs for passive TCP connection.
net.ipv4.tcp_synack_retries = 2

# Allowed local port range
net.ipv4.ip_local_port_range = 2000 65535

# Protect Against TCP Time-Wait
net.ipv4.tcp_rfc1337 = 1

# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 15

# Decrease the time default value for connections to keep alive
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15

### TUNING NETWORK PERFORMANCE ###

# Default Socket Receive Buffer
net.core.rmem_default = 31457280

# Maximum Socket Receive Buffer
net.core.rmem_max = 12582912

# Default Socket Send Buffer
net.core.wmem_default = 31457280

# Maximum Socket Send Buffer
net.core.wmem_max = 12582912

# Increase number of incoming connections
net.core.somaxconn = 65535

# Increase number of incoming connections backlog
net.core.netdev_max_backlog = 65535

# Increase the maximum amount of option memory buffers
net.core.optmem_max = 25165824

# Increase the maximum total buffer-space allocatable
# This is measured in units of pages (4096 bytes)
net.ipv4.tcp_mem = 65535 131072 262144
net.ipv4.udp_mem = 65535 131072 262144

# Increase the read-buffer space allocatable
net.ipv4.tcp_rmem = 8192 87380 16777216
net.ipv4.udp_rmem_min = 16384

# Increase the write-buffer-space allocatable
net.ipv4.tcp_wmem = 8192 65535 16777216
net.ipv4.udp_wmem_min = 16384

# Increase the tcp-time-wait buckets pool size to prevent simple DOS attacks
net.ipv4.tcp_max_tw_buckets = 1440000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1

Paste this (at the end of the file) to /etc/security/limits.conf (using nano /etc/security/limits.conf) and save it,

nginx           soft    nofile          2097152
nginx           hard    nofile          2097152
www-data        soft    nofile          2097152
www-data        hard    nofile          2097152

Paste this (at the end of the file) to /etc/pam.d/common-session (using nano /etc/pam.d/common-session) and save it,

session required pam_limits.so

Change listen.backlog in /etc/php5/fpm/pool.d/www.conf (using nano /etc/php5/fpm/pool.d/www.conf) and save it,

listen.backlog = 65535

Change workerrlimitnofile in /etc/nginx/nginx.conf (using nano /etc/nginx/nginx.conf) and save it,

worker_rlimit_nofile 99999;

And finally reboot :-)

@eldin please help me to fix "upstream: “fastcgi://unix:/var/run/php5-fpm.sock”. Pplease email me kusnendarebid(at)gmail(.)com. thanks