<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Nginx: connect() failed (111: Connection refused) while connecting to upstream]]></title><description><![CDATA[<p dir="auto">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</p>
<p dir="auto">Nginx error log</p>
<pre><code>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"

</code></pre>
<p dir="auto">My server block is</p>
<pre><code>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;
        }
}

</code></pre>
]]></description><link>https://lankadevelopers.lk/topic/73/nginx-connect-failed-111-connection-refused-while-connecting-to-upstream</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 21:17:41 GMT</lastBuildDate><atom:link href="https://lankadevelopers.lk/topic/73.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 05 Jan 2019 23:29:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Nginx: connect() failed (111: Connection refused) while connecting to upstream on Sun, 06 Jan 2019 07:18:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/130">@lkdev</a> said in <a href="/post/489">Nginx: connect() failed (111: Connection refused) while connecting to upstream</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/526">@crxssrazr93</a> said in <a href="/post/479">Nginx: connect() failed (111: Connection refused) while connecting to upstream</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/130">@lkdev</a></p>
<p dir="auto">Make sure php-fpm is already running on the background...</p>
<p dir="auto">Then, change your <code>listen 80;</code> to <code>listen 127.0.0.1;</code> .</p>
</blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/1">@ciaompe</a> said in <a href="/post/481">Nginx: connect() failed (111: Connection refused) while connecting to upstream</a>:</p>
<blockquote>
<p dir="auto">Simply, open the following path to your php5-fpm (if you php 7 then open php 7 fpm)</p>
<p dir="auto">Php 5</p>
<pre><code>sudo nano /etc/php5/fpm/pool.d/www.conf
</code></pre>
<p dir="auto">Php 7</p>
<pre><code>sudo nano /etc/php/7.2/fpm/pool.d/www.conf
</code></pre>
<p dir="auto">Then find this line and uncomment it:</p>
<pre><code>listen.allowed_clients = 127.0.0.1
</code></pre>
<p dir="auto">Also comment below line</p>
<hr />
<p dir="auto">Php 5</p>
<pre><code>;listen = /var/run/php5-fpm.sock 
</code></pre>
<p dir="auto">Php 7</p>
<pre><code>;listen = /run/php/php7.2-fpm.sock
</code></pre>
<p dir="auto">and add</p>
<hr />
<pre><code>listen = 9000
</code></pre>
<h3>after you make the modifications, all you need to restart or reload both Nginx and Php fpm</h3>
<p dir="auto">Php 5</p>
<pre><code>sudo service php5-fpm restart
</code></pre>
<p dir="auto">Php 7</p>
<pre><code>sudo service php7.2-fpm restart
</code></pre>
<p dir="auto">Nginx</p>
<pre><code>sudo service nginx restart
</code></pre>
</blockquote>
<p dir="auto">Guys this works. thanks aganin and lankadevelopers thank you very much</p>
</blockquote>
<p dir="auto">Anytime mate xD</p>
]]></description><link>https://lankadevelopers.lk/post/491</link><guid isPermaLink="true">https://lankadevelopers.lk/post/491</guid><dc:creator><![CDATA[crxssrazr93]]></dc:creator><pubDate>Sun, 06 Jan 2019 07:18:09 GMT</pubDate></item><item><title><![CDATA[Reply to Nginx: connect() failed (111: Connection refused) while connecting to upstream on Sun, 06 Jan 2019 06:41:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/526">@crxssrazr93</a> said in <a href="/post/479">Nginx: connect() failed (111: Connection refused) while connecting to upstream</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/130">@lkdev</a></p>
<p dir="auto">Make sure php-fpm is already running on the background...</p>
<p dir="auto">Then, change your <code>listen 80;</code> to <code>listen 127.0.0.1;</code> .</p>
</blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/1">@ciaompe</a> said in <a href="/post/481">Nginx: connect() failed (111: Connection refused) while connecting to upstream</a>:</p>
<blockquote>
<p dir="auto">Simply, open the following path to your php5-fpm (if you php 7 then open php 7 fpm)</p>
<p dir="auto">Php 5</p>
<pre><code>sudo nano /etc/php5/fpm/pool.d/www.conf
</code></pre>
<p dir="auto">Php 7</p>
<pre><code>sudo nano /etc/php/7.2/fpm/pool.d/www.conf
</code></pre>
<p dir="auto">Then find this line and uncomment it:</p>
<pre><code>listen.allowed_clients = 127.0.0.1
</code></pre>
<p dir="auto">Also comment below line</p>
<hr />
<p dir="auto">Php 5</p>
<pre><code>;listen = /var/run/php5-fpm.sock 
</code></pre>
<p dir="auto">Php 7</p>
<pre><code>;listen = /run/php/php7.2-fpm.sock
</code></pre>
<p dir="auto">and add</p>
<hr />
<pre><code>listen = 9000
</code></pre>
<h3>after you make the modifications, all you need to restart or reload both Nginx and Php fpm</h3>
<p dir="auto">Php 5</p>
<pre><code>sudo service php5-fpm restart
</code></pre>
<p dir="auto">Php 7</p>
<pre><code>sudo service php7.2-fpm restart
</code></pre>
<p dir="auto">Nginx</p>
<pre><code>sudo service nginx restart
</code></pre>
</blockquote>
<p dir="auto">Guys this works. thanks aganin and lankadevelopers thank you very much</p>
]]></description><link>https://lankadevelopers.lk/post/489</link><guid isPermaLink="true">https://lankadevelopers.lk/post/489</guid><dc:creator><![CDATA[lkdev]]></dc:creator><pubDate>Sun, 06 Jan 2019 06:41:55 GMT</pubDate></item><item><title><![CDATA[Reply to Nginx: connect() failed (111: Connection refused) while connecting to upstream on Sun, 06 Jan 2019 06:03:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/1">@ciaompe</a></p>
<p dir="auto">Thnx bro, i'll follow the steps</p>
]]></description><link>https://lankadevelopers.lk/post/483</link><guid isPermaLink="true">https://lankadevelopers.lk/post/483</guid><dc:creator><![CDATA[lkdev]]></dc:creator><pubDate>Sun, 06 Jan 2019 06:03:41 GMT</pubDate></item><item><title><![CDATA[Reply to Nginx: connect() failed (111: Connection refused) while connecting to upstream on Sun, 06 Jan 2019 06:03:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/526">@crxssrazr93</a></p>
<p dir="auto">Thnx Bro.</p>
]]></description><link>https://lankadevelopers.lk/post/482</link><guid isPermaLink="true">https://lankadevelopers.lk/post/482</guid><dc:creator><![CDATA[lkdev]]></dc:creator><pubDate>Sun, 06 Jan 2019 06:03:12 GMT</pubDate></item><item><title><![CDATA[Reply to Nginx: connect() failed (111: Connection refused) while connecting to upstream on Sun, 06 Jan 2019 05:55:17 GMT]]></title><description><![CDATA[<p dir="auto">Simply, open the following path to your php5-fpm (if you php 7 then open php 7 fpm)</p>
<p dir="auto">Php 5</p>
<pre><code>sudo nano /etc/php5/fpm/pool.d/www.conf
</code></pre>
<p dir="auto">Php 7</p>
<pre><code>sudo nano /etc/php/7.2/fpm/pool.d/www.conf
</code></pre>
<p dir="auto">Then find this line and uncomment it:</p>
<pre><code>listen.allowed_clients = 127.0.0.1
</code></pre>
<p dir="auto">Also comment below line</p>
<hr />
<p dir="auto">Php 5</p>
<pre><code>;listen = /var/run/php5-fpm.sock 
</code></pre>
<p dir="auto">Php 7</p>
<pre><code>;listen = /run/php/php7.2-fpm.sock
</code></pre>
<p dir="auto">and add</p>
<hr />
<pre><code>listen = 9000
</code></pre>
<h3>after you make the modifications, all you need to restart or reload both Nginx and Php fpm</h3>
<p dir="auto">Php 5</p>
<pre><code>sudo service php5-fpm restart
</code></pre>
<p dir="auto">Php 7</p>
<pre><code>sudo service php7.2-fpm restart
</code></pre>
<p dir="auto">Nginx</p>
<pre><code>sudo service nginx restart
</code></pre>
]]></description><link>https://lankadevelopers.lk/post/481</link><guid isPermaLink="true">https://lankadevelopers.lk/post/481</guid><dc:creator><![CDATA[ciaompe]]></dc:creator><pubDate>Sun, 06 Jan 2019 05:55:17 GMT</pubDate></item><item><title><![CDATA[Reply to Nginx: connect() failed (111: Connection refused) while connecting to upstream on Sun, 06 Jan 2019 05:39:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/130">@lkdev</a></p>
<p dir="auto">Make sure php-fpm is already running on the background...</p>
<p dir="auto">Then, change your <code>listen 80;</code> to <code>listen 127.0.0.1;</code> .</p>
]]></description><link>https://lankadevelopers.lk/post/479</link><guid isPermaLink="true">https://lankadevelopers.lk/post/479</guid><dc:creator><![CDATA[crxssrazr93]]></dc:creator><pubDate>Sun, 06 Jan 2019 05:39:21 GMT</pubDate></item></channel></rss>