Question

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

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

Subscribe
Share

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.

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

Hello,

Looking at your config file, it looks like 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

On a side note, here is also a quick video demo on how to troubleshoot such errors:

Hope that this helps! Bobby

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