Nginx connect() failed error

后端 未结 5 1564
生来不讨喜
生来不讨喜 2020-12-23 22:53

I don\'t know why I got this error every time I tried to open the page:

2013/04/06 17:52:19 [error] 5040#0: *1 connect() failed (111: Connection refused) whi         


        
相关标签:
5条回答
  • 2020-12-23 23:12

    I found I had this same issue with PHP7 running in Docker on a Debian Jessie (8.3) instance.

    • running command 'ps -aux' showed that php-fpm wasn't running
    • running 'php-fpm -D' brought it up as deamonized process.
    • Rerunning 'ps -aux' showed that php-fpm was indeed running
    • Refreshing my test page showed me the servers PHP info.

    Added 'php-fpm -D' to my start.sh script so that things started every time the container is loaded.

    Hope this helps someone.

    0 讨论(0)
  • 2020-12-23 23:15

    For me the problem was my php-fpm service wasn't running. You can check it by running:

    service php-fpm status
    

    and start it by running

    service php-fpm start
    

    Sometimes php-fpm might have broken instances running, preventing a restart. This command is a clean way to clear them out and restart php-fpm

    killall -9 php-fpm; service php-fpm restart
    
    0 讨论(0)
  • 2020-12-23 23:20

    Use fastcgi_pass unix:/var/run/php5-fpm.sock; only nginx and php install same server. If nginx and php install in other server you must use fastcgi_pass ip server:port;

    0 讨论(0)
  • 2020-12-23 23:24

    update your configurations as mentioned before:

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

    but don't forget to restart both nginx server and php-fpm after updating

    sudo /etc/init.d/nginx restart
    sudo /etc/init.d/php-fpm restart
    
    0 讨论(0)
  • 2020-12-23 23:31

    I resolved it, it was a configuration file issue, I added:

    location ~ .php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }
    
    0 讨论(0)
提交回复
热议问题