3

Every time when I try to publish my site, I get after a couple of minutes 502 Bad Gateway error, and in my default-error.log file I get this error over and over (file size was 360MB..):

2016/02/03 14:57:28 [error] 1044#1044: *7248 connect() to unix:/var/run/php/php7.0-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 123.456.78.90, server: default, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "domain.com"

Server Configuration

  • OS: Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-71-generic x86_64)
  • Nginx Version: 1.9.10
  • PHP Version PHP 7.0.2-4+deb.sury.org~trusty+1 (cli) ( NTS )
  • (My server is hosted in Digital Ocean and it has 4GB RAM).

nginx.conf:

server {
    listen 80 default_server;
    server_name default;
    root /home/forge/default/public;

    # FORGE SSL (DO NOT REMOVE!)
    include logjam_fix;
    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log on;
    error_log  /var/log/nginx/default-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

Is there any data I'm missing?

6
  • Could be you ran out of file descriptors. Feb 4, 2016 at 17:28
  • @MichaelHampton thank you for your reply. my experience with servers isn't quite well (sorry for that :), can you explain what do u exactly mean? Feb 4, 2016 at 17:30
  • Your error message indicates that PHP is using the Unix sockets while your nginx configuration is expecting PHP to run listen on a Fast CGI port. Make changes to the PHP.INI to use fast CGI. Apr 18, 2018 at 1:12
  • I have used CloudFlare's "Under Attack" Mode, which solved my issue. Apr 18, 2018 at 13:43
  • Cloudflare will serve only the content that it has cached. Try accessing the server ip directly to check if your issue is resolved. Apr 20, 2018 at 4:26

1 Answer 1

1

Try increasing the max number of open files:

root@server $ sysctl fs.file-max=3000000000

Edit:

You can usually have these changes be made permanent by adding the line to /etc/sysctl.conf:

fs.file-max=3000000000
3
  • Thank you for your reply, I set back online my server now. I'll see if the problem has been solved. Feb 4, 2016 at 17:43
  • Well it appears it solved my issue! But I'm curious, what does it have to do with my problem? Feb 4, 2016 at 18:56
  • It didn't help... Feb 6, 2016 at 17:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .