Nginx connect() failed (111: Connection refused) while connecting to upstream

July 11, 2019 9.7k views
Nginx Ubuntu 18.04 Linux Commands Let's Encrypt

Hi
I have the following error in the log
2019/07/11 01:33:38 [error] 31488#31488: *6 connect() failed (111: Connection refused) while connecting to upstream, client: 186.6.129.22, server: 127.0.0.1, request: “GET /favicon.ico HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: “myexample.com:8081”, referrer: “https://myexample.com:8081/

When I execute nginx -t show me
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

The configuration that I have is
server {

    server_name 127.0.0.1;
    root /var/www/html/moodle;
    index index.php;

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

    location /dataroot/ {
    internal;
    alias /var/moodledata/;
    }

    location ~ [^/]\.php(/|$){
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_index           index.php;
    fastcgi_pass            127.0.0.1:9000;
    include                 fastcgi_params;
    fastcgi_param   PATH_INFO       $fastcgi_path_info;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

Nginx works well for me when in the configuration disable
root /var/www/html/moodle;
index index.php;

Although what I want is to install moodle 3.6

3 Answers

ps axjf

1 1222 1222 1222 ? -1 Ss 0 0:47 php-fpm: master process (/etc/php/7.1/fpm/php-fpm.conf)
1222 1647 1222 1222 ? -1 S 33 0:00 _ php-fpm: pool www
1222 1651 1222 1222 ? -1 S 33 0:00 _ php-fpm: pool www
1 1227 1227 1227 ? -1 Ss 0 0:47 php-fpm: master process (/etc/php/7.3/fpm/php-fpm.conf)
1227 1660 1227 1227 ? -1 S 33 0:00 _ php-fpm: pool www
1227 1661 1227 1227 ? -1 S 33 0:00 _ php-fpm: pool www

  • OK PHP-FPM is running, but have you done the necessary configuration in your Nginx and PHP-FPM configuration files as described in the article?

    Regards,
    Bobby

Hello,

Looking at your config file, it looks like that you are trying to use PHP-FPM. First you need to make sure that PHP-FPM is installed and that you’ve configured it to listen on port 9000.

Here’s how to install and configure PHP-FPM with Nginx:

https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-ubuntu-18-04

Hope that this helps!
Bobby

by Justin Ellingwood
by Mark Drake
This tutorial details the process for installing and configuring the components that constitute a LEMP stack on an Ubuntu 18.04 server, including Nginx, MySQL, and PHP. It also includes instructions for testing that these components can communicate effectively and serve your content correctly.

ps aux | grep nginx
root 3946 0.0 0.1 142276 1652 ? Ss 12:28 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 3947 0.0 0.8 144912 8168 ? S 12:28 0:00 nginx: worker process
www-data 3948 0.0 0.8 144912 8168 ? S 12:28 0:00 nginx: worker process
root 4246 0.0 0.0 13136 984 pts/2 S+ 13:17 0:00 grep –color=auto nginx

Have another answer? Share your knowledge.