Nginx: connect() failed (111: Connection refused) while connecting to upstream
- 
					
					
					
					
 Hi guys, i'm new to nginx, i am getting 502 gateway timeout error. i want to execute php with nginx server. my server is running on ubuntu 18.04 Nginx error log 2019/01/05 09:17:59 [error] 30189#30189: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 95.235.148.111, server: mysite.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mysite.com"My server block is server { listen 80; root /var/www/html; index index.php index.html index.htm index.nginx-debian.html; server_name mysite.com; location / { try_files $uri $uri/ =404; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }
- 
					
					
					
					
 Make sure php-fpm is already running on the background... Then, change your listen 80;tolisten 127.0.0.1;.
- 
					
					
					
					
 Simply, open the following path to your php5-fpm (if you php 7 then open php 7 fpm) Php 5 sudo nano /etc/php5/fpm/pool.d/www.confPhp 7 sudo nano /etc/php/7.2/fpm/pool.d/www.confThen find this line and uncomment it: listen.allowed_clients = 127.0.0.1Also comment below line 
 Php 5 ;listen = /var/run/php5-fpm.sockPhp 7 ;listen = /run/php/php7.2-fpm.sockand add 
 listen = 9000after you make the modifications, all you need to restart or reload both Nginx and Php fpmPhp 5 sudo service php5-fpm restartPhp 7 sudo service php7.2-fpm restartNginx sudo service nginx restart
- 
					
					
					
					
 Thnx Bro. 
- 
					
					
					
					
 Thnx bro, i'll follow the steps 
- 
					
					
					
					
 @crxssrazr93 said in Nginx: connect() failed (111: Connection refused) while connecting to upstream: Make sure php-fpm is already running on the background... Then, change your listen 80;tolisten 127.0.0.1;.@ciaompe said in Nginx: connect() failed (111: Connection refused) while connecting to upstream: Simply, open the following path to your php5-fpm (if you php 7 then open php 7 fpm) Php 5 sudo nano /etc/php5/fpm/pool.d/www.confPhp 7 sudo nano /etc/php/7.2/fpm/pool.d/www.confThen find this line and uncomment it: listen.allowed_clients = 127.0.0.1Also comment below line 
 Php 5 ;listen = /var/run/php5-fpm.sockPhp 7 ;listen = /run/php/php7.2-fpm.sockand add 
 listen = 9000after you make the modifications, all you need to restart or reload both Nginx and Php fpmPhp 5 sudo service php5-fpm restartPhp 7 sudo service php7.2-fpm restartNginx sudo service nginx restartGuys this works. thanks aganin and lankadevelopers thank you very much 
- 
					
					
					
					
 @lkdev said in Nginx: connect() failed (111: Connection refused) while connecting to upstream: @crxssrazr93 said in Nginx: connect() failed (111: Connection refused) while connecting to upstream: Make sure php-fpm is already running on the background... Then, change your listen 80;tolisten 127.0.0.1;.@ciaompe said in Nginx: connect() failed (111: Connection refused) while connecting to upstream: Simply, open the following path to your php5-fpm (if you php 7 then open php 7 fpm) Php 5 sudo nano /etc/php5/fpm/pool.d/www.confPhp 7 sudo nano /etc/php/7.2/fpm/pool.d/www.confThen find this line and uncomment it: listen.allowed_clients = 127.0.0.1Also comment below line 
 Php 5 ;listen = /var/run/php5-fpm.sockPhp 7 ;listen = /run/php/php7.2-fpm.sockand add 
 listen = 9000after you make the modifications, all you need to restart or reload both Nginx and Php fpmPhp 5 sudo service php5-fpm restartPhp 7 sudo service php7.2-fpm restartNginx sudo service nginx restartGuys this works. thanks aganin and lankadevelopers thank you very much Anytime mate xD 
 
			
		 
			
		