connect() failed (111: Connection refused) while connecting to upstream*2 connect() failed (111: Connection...
How Could an Airship Be Repaired Mid-Flight
If I can solve Sudoku can I solve Travelling Salesman Problem(TSP)? If yes, how?
Gantt Chart like rectangles with log scale
Science-fiction short story where space navy wanted hospital ships and settlers had guns mounted everywhere
How to read the value of this capacitor?
Why did it take so long to abandon sail after steamships were demonstrated?
What did Alexander Pope mean by "Expletives their feeble Aid do join"?
How do I hide Chekhov's Gun?
Brexit - No Deal Rejection
Is it possible to upcast ritual spells?
Why do Australian milk farmers need to protest supermarkets' milk price?
Bach's Toccata and Fugue in D minor breaks the "no parallel octaves" rule?
Knife as defense against stray dogs
In a future war, an old lady is trying to raise a boy but one of the weapons has made everyone deaf
Adventure Game (text based) in C++
How difficult is it to simply disable/disengage the MCAS on Boeing 737 Max 8 & 9 Aircraft?
Interplanetary conflict, some disease destroys the ability to understand or appreciate music
How to deal with taxi scam when on vacation?
SOQL: Populate a Literal List in WHERE IN Clause
Sailing the cryptic seas
Dice rolling probability game
How to make healing in an exploration game interesting
Welcoming 2019 Pi day: How to draw the letter π?
Creature kill and resurrect effects on the stack interaction?
connect() failed (111: Connection refused) while connecting to upstream
*2 connect() failed (111: Connection refused) while connecting to upstreamHelp needed setting up nginx to serve static filesConfigure php5-fpm for many concurrent usersNginx gives 504 Gateway Time-out once moved to livenginx: connect() failed (111: Connection refused) while connecting to upstreamNginX + WordPress + SSL + non-www + W3TC vhost config file questionsChange Nginx document root from /usr/share/nginx to /etc/nginx403 Forbidden nginx (nginx/1.8.0)nginx configuration troubleWhy the .css and .js files of my website aren't compressedNGINX not accessing folder
I'm experiencing 502 Gateway
errors when accessing a PHP file in a directory (http://example.com/dev/index.php
). The logs simply says this:
2011/09/30 23:47:54 [error] 31160#0: *35 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: domain.com, request: "GET /dev/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "domain.com"
I've never experienced this before. What is the solution for this type of 502 Gateway
error?
This is the nginx.conf
:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
nginx 502-error
add a comment |
I'm experiencing 502 Gateway
errors when accessing a PHP file in a directory (http://example.com/dev/index.php
). The logs simply says this:
2011/09/30 23:47:54 [error] 31160#0: *35 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: domain.com, request: "GET /dev/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "domain.com"
I've never experienced this before. What is the solution for this type of 502 Gateway
error?
This is the nginx.conf
:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
nginx 502-error
1
'Connection refused' means that backend does not listen to the port 9000 or its queue is filled up. This problem is related to the backend itsef. Are you able to telnet localhost 9000? You should also check your backend and php logs.
– Andrew
Oct 1 '11 at 9:17
Updated my post. I could not telnet to localhost 9000.
– MacMac
Oct 1 '11 at 10:48
The same error I was facing you, This enter link description here can help you
– Tripathi29
Nov 2 '15 at 13:53
add a comment |
I'm experiencing 502 Gateway
errors when accessing a PHP file in a directory (http://example.com/dev/index.php
). The logs simply says this:
2011/09/30 23:47:54 [error] 31160#0: *35 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: domain.com, request: "GET /dev/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "domain.com"
I've never experienced this before. What is the solution for this type of 502 Gateway
error?
This is the nginx.conf
:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
nginx 502-error
I'm experiencing 502 Gateway
errors when accessing a PHP file in a directory (http://example.com/dev/index.php
). The logs simply says this:
2011/09/30 23:47:54 [error] 31160#0: *35 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: domain.com, request: "GET /dev/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "domain.com"
I've never experienced this before. What is the solution for this type of 502 Gateway
error?
This is the nginx.conf
:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
nginx 502-error
nginx 502-error
edited 5 mins ago
Chalist
1158
1158
asked Sep 30 '11 at 21:59
MacMacMacMac
53972136
53972136
1
'Connection refused' means that backend does not listen to the port 9000 or its queue is filled up. This problem is related to the backend itsef. Are you able to telnet localhost 9000? You should also check your backend and php logs.
– Andrew
Oct 1 '11 at 9:17
Updated my post. I could not telnet to localhost 9000.
– MacMac
Oct 1 '11 at 10:48
The same error I was facing you, This enter link description here can help you
– Tripathi29
Nov 2 '15 at 13:53
add a comment |
1
'Connection refused' means that backend does not listen to the port 9000 or its queue is filled up. This problem is related to the backend itsef. Are you able to telnet localhost 9000? You should also check your backend and php logs.
– Andrew
Oct 1 '11 at 9:17
Updated my post. I could not telnet to localhost 9000.
– MacMac
Oct 1 '11 at 10:48
The same error I was facing you, This enter link description here can help you
– Tripathi29
Nov 2 '15 at 13:53
1
1
'Connection refused' means that backend does not listen to the port 9000 or its queue is filled up. This problem is related to the backend itsef. Are you able to telnet localhost 9000? You should also check your backend and php logs.
– Andrew
Oct 1 '11 at 9:17
'Connection refused' means that backend does not listen to the port 9000 or its queue is filled up. This problem is related to the backend itsef. Are you able to telnet localhost 9000? You should also check your backend and php logs.
– Andrew
Oct 1 '11 at 9:17
Updated my post. I could not telnet to localhost 9000.
– MacMac
Oct 1 '11 at 10:48
Updated my post. I could not telnet to localhost 9000.
– MacMac
Oct 1 '11 at 10:48
The same error I was facing you, This enter link description here can help you
– Tripathi29
Nov 2 '15 at 13:53
The same error I was facing you, This enter link description here can help you
– Tripathi29
Nov 2 '15 at 13:53
add a comment |
6 Answers
6
active
oldest
votes
It sounds like you haven't started and configured the backend for Nginx. Start php-fpm
and add the following to nginx.conf
, in the http
context:
server {
listen 127.0.0.1;
server_name localhost;
error_log /var/log/nginx/localhost.error_log info;
root /var/www/localhost/htdocs;
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
fastcgi_intercept_errors on;
error_page 404 /error/404.php;
}
}
3
Thanks man, it worked, I didn't havephp-fpm
installed. Cheers.
– MacMac
Oct 1 '11 at 11:21
6
You're pure genius. I can't believe 1.0000000 million guides I read about this, NOBODY mentions that you must put a "listen 127.0.0.1" to enable backend. You saved me from a nightmare!!!
– user145046
Nov 11 '12 at 19:39
you should consider to use the unix socket. View it withnetstat -l
and see for/var/run/php5-fpm.sock
(the config for this is normally in /etc/php5/fpm/pool.d/www.conf.fastcgi_pass unix:<socket>
– JohannesM
May 22 '14 at 13:59
2
you will havelisten = /var/run/php5-fpm.sock
inside/etc/php5/fpm/pool.d/www.conf
. but you will wantlisten = 9000
and;listen = /var/run/php5-fpm.sock
. if you were like me. (or else alternatively you could listen to wise hint by JohannesM. which I imagine would leave you with something likefastcgi_pass unix:/var/run/php5-fpm.sock;
somewhere in yournginx.conf
)
– n611x007
Jan 1 '15 at 16:20
Having the same issue with php 7.2. What do you mean by add the file in the httpd context? Would this be an additional conf file in /etc/nginx/sites-available/ folder or what?
– PeterKA
Feb 1 '18 at 14:56
add a comment |
This answer is only for those who get an error like this:
connect() failed (111: Connection refused) while connecting to upstream, client ....
fastcgi://[::1]:9000
Rewrite your nginx config to use ip, not dns. For instance, 127.0.0.1
instead of localhost
, or remove the ipv6 alias from /etc/hosts.
3
You pointed my in the right direction! I though using justlisten 80
was fine (and there are lots of examples out there with that) but I didn't thought that implied both IPv4 (127.0.0.1
) and IPv6 ([::1]
) addresses.
– glarrain
Aug 12 '14 at 0:15
5
I had to change fromlisten 80 default_server
tolisten 0.0.0.0:80
.
– givanse
Nov 12 '14 at 6:00
Can you point out why this should help?
– kaiser
Feb 9 '16 at 2:38
1
Becouse most linux distributions have ipv6 enabled in networking, but not all packets configured for ipv6 use. In my opinion, when nginx initiates connection to upstream, system resolver returns ipv6 adress first. Php-fpm (centos 7.x) had no such settings from box. And most guides explain all in ipv4 version, forgetting about ipv6 futures that should be disabled or used.
– Quake1TF
Feb 9 '16 at 14:54
Whooah, so [::1] is localhost IPv6 address! :) Thanks!
– lechup
Jan 4 '17 at 11:08
add a comment |
Got errors like this too.
Problem was my abstract backend referencing two servers.
php-fpm
was only listing to socket...
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/var/run/php5-fpm.sock;
#server 127.0.0.1:9000;
}
server {
[...]
location ~ .php$ {
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-fpm:
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_intercept_errors on;
include fastcgi_params;
}
}
add a comment |
Had the same problem with proxied requests to a Node server listening on port 5000. Requests would result with 200 OK
but sometime 502 Bad Gateway
randomly. NGINX showed the error:
connect() failed (111: Connection refused) while connecting to upstream, client: ..., server: ...
My solution:
- Set node HTTP server to listen strictly for ipv4 by including
localhost as host:server.listen(5000, 'localhost');
- Removed any ipv6 listen directives (
listen [::]:80;
orlisten
).
[::]:443 ssl default_server; - Changed location block proxy_pass to use IPs:
proxy_pass http://127.0.0.1:5000
(notproxy_pass http://localhost:5000
).
Hope this helps someone.
add a comment |
In my case the error was a bad location for the error_log file for php5.6-fpm service and thus the php-fpm service was failing to start and nginx was not able to connect to it. You can find it in /etc/php/5.6/fpm/php.ini
(you can replace 5.6 with the version you are running).
add a comment |
I had the same problem and adding the listen statement
listen 127.0.0.1;
worked for me.
Interestingly enough I have other server blocks that are running quite happily without this!
3
This has been answered and accepted already, three years ago.
– Sven♦
Nov 26 '14 at 23:13
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f317393%2fconnect-failed-111-connection-refused-while-connecting-to-upstream%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
It sounds like you haven't started and configured the backend for Nginx. Start php-fpm
and add the following to nginx.conf
, in the http
context:
server {
listen 127.0.0.1;
server_name localhost;
error_log /var/log/nginx/localhost.error_log info;
root /var/www/localhost/htdocs;
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
fastcgi_intercept_errors on;
error_page 404 /error/404.php;
}
}
3
Thanks man, it worked, I didn't havephp-fpm
installed. Cheers.
– MacMac
Oct 1 '11 at 11:21
6
You're pure genius. I can't believe 1.0000000 million guides I read about this, NOBODY mentions that you must put a "listen 127.0.0.1" to enable backend. You saved me from a nightmare!!!
– user145046
Nov 11 '12 at 19:39
you should consider to use the unix socket. View it withnetstat -l
and see for/var/run/php5-fpm.sock
(the config for this is normally in /etc/php5/fpm/pool.d/www.conf.fastcgi_pass unix:<socket>
– JohannesM
May 22 '14 at 13:59
2
you will havelisten = /var/run/php5-fpm.sock
inside/etc/php5/fpm/pool.d/www.conf
. but you will wantlisten = 9000
and;listen = /var/run/php5-fpm.sock
. if you were like me. (or else alternatively you could listen to wise hint by JohannesM. which I imagine would leave you with something likefastcgi_pass unix:/var/run/php5-fpm.sock;
somewhere in yournginx.conf
)
– n611x007
Jan 1 '15 at 16:20
Having the same issue with php 7.2. What do you mean by add the file in the httpd context? Would this be an additional conf file in /etc/nginx/sites-available/ folder or what?
– PeterKA
Feb 1 '18 at 14:56
add a comment |
It sounds like you haven't started and configured the backend for Nginx. Start php-fpm
and add the following to nginx.conf
, in the http
context:
server {
listen 127.0.0.1;
server_name localhost;
error_log /var/log/nginx/localhost.error_log info;
root /var/www/localhost/htdocs;
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
fastcgi_intercept_errors on;
error_page 404 /error/404.php;
}
}
3
Thanks man, it worked, I didn't havephp-fpm
installed. Cheers.
– MacMac
Oct 1 '11 at 11:21
6
You're pure genius. I can't believe 1.0000000 million guides I read about this, NOBODY mentions that you must put a "listen 127.0.0.1" to enable backend. You saved me from a nightmare!!!
– user145046
Nov 11 '12 at 19:39
you should consider to use the unix socket. View it withnetstat -l
and see for/var/run/php5-fpm.sock
(the config for this is normally in /etc/php5/fpm/pool.d/www.conf.fastcgi_pass unix:<socket>
– JohannesM
May 22 '14 at 13:59
2
you will havelisten = /var/run/php5-fpm.sock
inside/etc/php5/fpm/pool.d/www.conf
. but you will wantlisten = 9000
and;listen = /var/run/php5-fpm.sock
. if you were like me. (or else alternatively you could listen to wise hint by JohannesM. which I imagine would leave you with something likefastcgi_pass unix:/var/run/php5-fpm.sock;
somewhere in yournginx.conf
)
– n611x007
Jan 1 '15 at 16:20
Having the same issue with php 7.2. What do you mean by add the file in the httpd context? Would this be an additional conf file in /etc/nginx/sites-available/ folder or what?
– PeterKA
Feb 1 '18 at 14:56
add a comment |
It sounds like you haven't started and configured the backend for Nginx. Start php-fpm
and add the following to nginx.conf
, in the http
context:
server {
listen 127.0.0.1;
server_name localhost;
error_log /var/log/nginx/localhost.error_log info;
root /var/www/localhost/htdocs;
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
fastcgi_intercept_errors on;
error_page 404 /error/404.php;
}
}
It sounds like you haven't started and configured the backend for Nginx. Start php-fpm
and add the following to nginx.conf
, in the http
context:
server {
listen 127.0.0.1;
server_name localhost;
error_log /var/log/nginx/localhost.error_log info;
root /var/www/localhost/htdocs;
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
fastcgi_intercept_errors on;
error_page 404 /error/404.php;
}
}
edited Jul 28 '17 at 21:49
Nathaniel Ford
1095
1095
answered Oct 1 '11 at 11:03
quantaquanta
43.2k15113196
43.2k15113196
3
Thanks man, it worked, I didn't havephp-fpm
installed. Cheers.
– MacMac
Oct 1 '11 at 11:21
6
You're pure genius. I can't believe 1.0000000 million guides I read about this, NOBODY mentions that you must put a "listen 127.0.0.1" to enable backend. You saved me from a nightmare!!!
– user145046
Nov 11 '12 at 19:39
you should consider to use the unix socket. View it withnetstat -l
and see for/var/run/php5-fpm.sock
(the config for this is normally in /etc/php5/fpm/pool.d/www.conf.fastcgi_pass unix:<socket>
– JohannesM
May 22 '14 at 13:59
2
you will havelisten = /var/run/php5-fpm.sock
inside/etc/php5/fpm/pool.d/www.conf
. but you will wantlisten = 9000
and;listen = /var/run/php5-fpm.sock
. if you were like me. (or else alternatively you could listen to wise hint by JohannesM. which I imagine would leave you with something likefastcgi_pass unix:/var/run/php5-fpm.sock;
somewhere in yournginx.conf
)
– n611x007
Jan 1 '15 at 16:20
Having the same issue with php 7.2. What do you mean by add the file in the httpd context? Would this be an additional conf file in /etc/nginx/sites-available/ folder or what?
– PeterKA
Feb 1 '18 at 14:56
add a comment |
3
Thanks man, it worked, I didn't havephp-fpm
installed. Cheers.
– MacMac
Oct 1 '11 at 11:21
6
You're pure genius. I can't believe 1.0000000 million guides I read about this, NOBODY mentions that you must put a "listen 127.0.0.1" to enable backend. You saved me from a nightmare!!!
– user145046
Nov 11 '12 at 19:39
you should consider to use the unix socket. View it withnetstat -l
and see for/var/run/php5-fpm.sock
(the config for this is normally in /etc/php5/fpm/pool.d/www.conf.fastcgi_pass unix:<socket>
– JohannesM
May 22 '14 at 13:59
2
you will havelisten = /var/run/php5-fpm.sock
inside/etc/php5/fpm/pool.d/www.conf
. but you will wantlisten = 9000
and;listen = /var/run/php5-fpm.sock
. if you were like me. (or else alternatively you could listen to wise hint by JohannesM. which I imagine would leave you with something likefastcgi_pass unix:/var/run/php5-fpm.sock;
somewhere in yournginx.conf
)
– n611x007
Jan 1 '15 at 16:20
Having the same issue with php 7.2. What do you mean by add the file in the httpd context? Would this be an additional conf file in /etc/nginx/sites-available/ folder or what?
– PeterKA
Feb 1 '18 at 14:56
3
3
Thanks man, it worked, I didn't have
php-fpm
installed. Cheers.– MacMac
Oct 1 '11 at 11:21
Thanks man, it worked, I didn't have
php-fpm
installed. Cheers.– MacMac
Oct 1 '11 at 11:21
6
6
You're pure genius. I can't believe 1.0000000 million guides I read about this, NOBODY mentions that you must put a "listen 127.0.0.1" to enable backend. You saved me from a nightmare!!!
– user145046
Nov 11 '12 at 19:39
You're pure genius. I can't believe 1.0000000 million guides I read about this, NOBODY mentions that you must put a "listen 127.0.0.1" to enable backend. You saved me from a nightmare!!!
– user145046
Nov 11 '12 at 19:39
you should consider to use the unix socket. View it with
netstat -l
and see for /var/run/php5-fpm.sock
(the config for this is normally in /etc/php5/fpm/pool.d/www.conf. fastcgi_pass unix:<socket>
– JohannesM
May 22 '14 at 13:59
you should consider to use the unix socket. View it with
netstat -l
and see for /var/run/php5-fpm.sock
(the config for this is normally in /etc/php5/fpm/pool.d/www.conf. fastcgi_pass unix:<socket>
– JohannesM
May 22 '14 at 13:59
2
2
you will have
listen = /var/run/php5-fpm.sock
inside /etc/php5/fpm/pool.d/www.conf
. but you will want listen = 9000
and ;listen = /var/run/php5-fpm.sock
. if you were like me. (or else alternatively you could listen to wise hint by JohannesM. which I imagine would leave you with something like fastcgi_pass unix:/var/run/php5-fpm.sock;
somewhere in your nginx.conf
)– n611x007
Jan 1 '15 at 16:20
you will have
listen = /var/run/php5-fpm.sock
inside /etc/php5/fpm/pool.d/www.conf
. but you will want listen = 9000
and ;listen = /var/run/php5-fpm.sock
. if you were like me. (or else alternatively you could listen to wise hint by JohannesM. which I imagine would leave you with something like fastcgi_pass unix:/var/run/php5-fpm.sock;
somewhere in your nginx.conf
)– n611x007
Jan 1 '15 at 16:20
Having the same issue with php 7.2. What do you mean by add the file in the httpd context? Would this be an additional conf file in /etc/nginx/sites-available/ folder or what?
– PeterKA
Feb 1 '18 at 14:56
Having the same issue with php 7.2. What do you mean by add the file in the httpd context? Would this be an additional conf file in /etc/nginx/sites-available/ folder or what?
– PeterKA
Feb 1 '18 at 14:56
add a comment |
This answer is only for those who get an error like this:
connect() failed (111: Connection refused) while connecting to upstream, client ....
fastcgi://[::1]:9000
Rewrite your nginx config to use ip, not dns. For instance, 127.0.0.1
instead of localhost
, or remove the ipv6 alias from /etc/hosts.
3
You pointed my in the right direction! I though using justlisten 80
was fine (and there are lots of examples out there with that) but I didn't thought that implied both IPv4 (127.0.0.1
) and IPv6 ([::1]
) addresses.
– glarrain
Aug 12 '14 at 0:15
5
I had to change fromlisten 80 default_server
tolisten 0.0.0.0:80
.
– givanse
Nov 12 '14 at 6:00
Can you point out why this should help?
– kaiser
Feb 9 '16 at 2:38
1
Becouse most linux distributions have ipv6 enabled in networking, but not all packets configured for ipv6 use. In my opinion, when nginx initiates connection to upstream, system resolver returns ipv6 adress first. Php-fpm (centos 7.x) had no such settings from box. And most guides explain all in ipv4 version, forgetting about ipv6 futures that should be disabled or used.
– Quake1TF
Feb 9 '16 at 14:54
Whooah, so [::1] is localhost IPv6 address! :) Thanks!
– lechup
Jan 4 '17 at 11:08
add a comment |
This answer is only for those who get an error like this:
connect() failed (111: Connection refused) while connecting to upstream, client ....
fastcgi://[::1]:9000
Rewrite your nginx config to use ip, not dns. For instance, 127.0.0.1
instead of localhost
, or remove the ipv6 alias from /etc/hosts.
3
You pointed my in the right direction! I though using justlisten 80
was fine (and there are lots of examples out there with that) but I didn't thought that implied both IPv4 (127.0.0.1
) and IPv6 ([::1]
) addresses.
– glarrain
Aug 12 '14 at 0:15
5
I had to change fromlisten 80 default_server
tolisten 0.0.0.0:80
.
– givanse
Nov 12 '14 at 6:00
Can you point out why this should help?
– kaiser
Feb 9 '16 at 2:38
1
Becouse most linux distributions have ipv6 enabled in networking, but not all packets configured for ipv6 use. In my opinion, when nginx initiates connection to upstream, system resolver returns ipv6 adress first. Php-fpm (centos 7.x) had no such settings from box. And most guides explain all in ipv4 version, forgetting about ipv6 futures that should be disabled or used.
– Quake1TF
Feb 9 '16 at 14:54
Whooah, so [::1] is localhost IPv6 address! :) Thanks!
– lechup
Jan 4 '17 at 11:08
add a comment |
This answer is only for those who get an error like this:
connect() failed (111: Connection refused) while connecting to upstream, client ....
fastcgi://[::1]:9000
Rewrite your nginx config to use ip, not dns. For instance, 127.0.0.1
instead of localhost
, or remove the ipv6 alias from /etc/hosts.
This answer is only for those who get an error like this:
connect() failed (111: Connection refused) while connecting to upstream, client ....
fastcgi://[::1]:9000
Rewrite your nginx config to use ip, not dns. For instance, 127.0.0.1
instead of localhost
, or remove the ipv6 alias from /etc/hosts.
edited Jul 28 '17 at 8:53
Nathaniel Ford
1095
1095
answered Feb 18 '14 at 15:58
Quake1TFQuake1TF
51144
51144
3
You pointed my in the right direction! I though using justlisten 80
was fine (and there are lots of examples out there with that) but I didn't thought that implied both IPv4 (127.0.0.1
) and IPv6 ([::1]
) addresses.
– glarrain
Aug 12 '14 at 0:15
5
I had to change fromlisten 80 default_server
tolisten 0.0.0.0:80
.
– givanse
Nov 12 '14 at 6:00
Can you point out why this should help?
– kaiser
Feb 9 '16 at 2:38
1
Becouse most linux distributions have ipv6 enabled in networking, but not all packets configured for ipv6 use. In my opinion, when nginx initiates connection to upstream, system resolver returns ipv6 adress first. Php-fpm (centos 7.x) had no such settings from box. And most guides explain all in ipv4 version, forgetting about ipv6 futures that should be disabled or used.
– Quake1TF
Feb 9 '16 at 14:54
Whooah, so [::1] is localhost IPv6 address! :) Thanks!
– lechup
Jan 4 '17 at 11:08
add a comment |
3
You pointed my in the right direction! I though using justlisten 80
was fine (and there are lots of examples out there with that) but I didn't thought that implied both IPv4 (127.0.0.1
) and IPv6 ([::1]
) addresses.
– glarrain
Aug 12 '14 at 0:15
5
I had to change fromlisten 80 default_server
tolisten 0.0.0.0:80
.
– givanse
Nov 12 '14 at 6:00
Can you point out why this should help?
– kaiser
Feb 9 '16 at 2:38
1
Becouse most linux distributions have ipv6 enabled in networking, but not all packets configured for ipv6 use. In my opinion, when nginx initiates connection to upstream, system resolver returns ipv6 adress first. Php-fpm (centos 7.x) had no such settings from box. And most guides explain all in ipv4 version, forgetting about ipv6 futures that should be disabled or used.
– Quake1TF
Feb 9 '16 at 14:54
Whooah, so [::1] is localhost IPv6 address! :) Thanks!
– lechup
Jan 4 '17 at 11:08
3
3
You pointed my in the right direction! I though using just
listen 80
was fine (and there are lots of examples out there with that) but I didn't thought that implied both IPv4 (127.0.0.1
) and IPv6 ([::1]
) addresses.– glarrain
Aug 12 '14 at 0:15
You pointed my in the right direction! I though using just
listen 80
was fine (and there are lots of examples out there with that) but I didn't thought that implied both IPv4 (127.0.0.1
) and IPv6 ([::1]
) addresses.– glarrain
Aug 12 '14 at 0:15
5
5
I had to change from
listen 80 default_server
to listen 0.0.0.0:80
.– givanse
Nov 12 '14 at 6:00
I had to change from
listen 80 default_server
to listen 0.0.0.0:80
.– givanse
Nov 12 '14 at 6:00
Can you point out why this should help?
– kaiser
Feb 9 '16 at 2:38
Can you point out why this should help?
– kaiser
Feb 9 '16 at 2:38
1
1
Becouse most linux distributions have ipv6 enabled in networking, but not all packets configured for ipv6 use. In my opinion, when nginx initiates connection to upstream, system resolver returns ipv6 adress first. Php-fpm (centos 7.x) had no such settings from box. And most guides explain all in ipv4 version, forgetting about ipv6 futures that should be disabled or used.
– Quake1TF
Feb 9 '16 at 14:54
Becouse most linux distributions have ipv6 enabled in networking, but not all packets configured for ipv6 use. In my opinion, when nginx initiates connection to upstream, system resolver returns ipv6 adress first. Php-fpm (centos 7.x) had no such settings from box. And most guides explain all in ipv4 version, forgetting about ipv6 futures that should be disabled or used.
– Quake1TF
Feb 9 '16 at 14:54
Whooah, so [::1] is localhost IPv6 address! :) Thanks!
– lechup
Jan 4 '17 at 11:08
Whooah, so [::1] is localhost IPv6 address! :) Thanks!
– lechup
Jan 4 '17 at 11:08
add a comment |
Got errors like this too.
Problem was my abstract backend referencing two servers.
php-fpm
was only listing to socket...
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/var/run/php5-fpm.sock;
#server 127.0.0.1:9000;
}
server {
[...]
location ~ .php$ {
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-fpm:
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_intercept_errors on;
include fastcgi_params;
}
}
add a comment |
Got errors like this too.
Problem was my abstract backend referencing two servers.
php-fpm
was only listing to socket...
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/var/run/php5-fpm.sock;
#server 127.0.0.1:9000;
}
server {
[...]
location ~ .php$ {
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-fpm:
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_intercept_errors on;
include fastcgi_params;
}
}
add a comment |
Got errors like this too.
Problem was my abstract backend referencing two servers.
php-fpm
was only listing to socket...
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/var/run/php5-fpm.sock;
#server 127.0.0.1:9000;
}
server {
[...]
location ~ .php$ {
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-fpm:
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_intercept_errors on;
include fastcgi_params;
}
}
Got errors like this too.
Problem was my abstract backend referencing two servers.
php-fpm
was only listing to socket...
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/var/run/php5-fpm.sock;
#server 127.0.0.1:9000;
}
server {
[...]
location ~ .php$ {
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-fpm:
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_intercept_errors on;
include fastcgi_params;
}
}
answered May 22 '14 at 13:45
KumZKumZ
1312
1312
add a comment |
add a comment |
Had the same problem with proxied requests to a Node server listening on port 5000. Requests would result with 200 OK
but sometime 502 Bad Gateway
randomly. NGINX showed the error:
connect() failed (111: Connection refused) while connecting to upstream, client: ..., server: ...
My solution:
- Set node HTTP server to listen strictly for ipv4 by including
localhost as host:server.listen(5000, 'localhost');
- Removed any ipv6 listen directives (
listen [::]:80;
orlisten
).
[::]:443 ssl default_server; - Changed location block proxy_pass to use IPs:
proxy_pass http://127.0.0.1:5000
(notproxy_pass http://localhost:5000
).
Hope this helps someone.
add a comment |
Had the same problem with proxied requests to a Node server listening on port 5000. Requests would result with 200 OK
but sometime 502 Bad Gateway
randomly. NGINX showed the error:
connect() failed (111: Connection refused) while connecting to upstream, client: ..., server: ...
My solution:
- Set node HTTP server to listen strictly for ipv4 by including
localhost as host:server.listen(5000, 'localhost');
- Removed any ipv6 listen directives (
listen [::]:80;
orlisten
).
[::]:443 ssl default_server; - Changed location block proxy_pass to use IPs:
proxy_pass http://127.0.0.1:5000
(notproxy_pass http://localhost:5000
).
Hope this helps someone.
add a comment |
Had the same problem with proxied requests to a Node server listening on port 5000. Requests would result with 200 OK
but sometime 502 Bad Gateway
randomly. NGINX showed the error:
connect() failed (111: Connection refused) while connecting to upstream, client: ..., server: ...
My solution:
- Set node HTTP server to listen strictly for ipv4 by including
localhost as host:server.listen(5000, 'localhost');
- Removed any ipv6 listen directives (
listen [::]:80;
orlisten
).
[::]:443 ssl default_server; - Changed location block proxy_pass to use IPs:
proxy_pass http://127.0.0.1:5000
(notproxy_pass http://localhost:5000
).
Hope this helps someone.
Had the same problem with proxied requests to a Node server listening on port 5000. Requests would result with 200 OK
but sometime 502 Bad Gateway
randomly. NGINX showed the error:
connect() failed (111: Connection refused) while connecting to upstream, client: ..., server: ...
My solution:
- Set node HTTP server to listen strictly for ipv4 by including
localhost as host:server.listen(5000, 'localhost');
- Removed any ipv6 listen directives (
listen [::]:80;
orlisten
).
[::]:443 ssl default_server; - Changed location block proxy_pass to use IPs:
proxy_pass http://127.0.0.1:5000
(notproxy_pass http://localhost:5000
).
Hope this helps someone.
answered Jul 5 '18 at 10:05
Niko SolihinNiko Solihin
111
111
add a comment |
add a comment |
In my case the error was a bad location for the error_log file for php5.6-fpm service and thus the php-fpm service was failing to start and nginx was not able to connect to it. You can find it in /etc/php/5.6/fpm/php.ini
(you can replace 5.6 with the version you are running).
add a comment |
In my case the error was a bad location for the error_log file for php5.6-fpm service and thus the php-fpm service was failing to start and nginx was not able to connect to it. You can find it in /etc/php/5.6/fpm/php.ini
(you can replace 5.6 with the version you are running).
add a comment |
In my case the error was a bad location for the error_log file for php5.6-fpm service and thus the php-fpm service was failing to start and nginx was not able to connect to it. You can find it in /etc/php/5.6/fpm/php.ini
(you can replace 5.6 with the version you are running).
In my case the error was a bad location for the error_log file for php5.6-fpm service and thus the php-fpm service was failing to start and nginx was not able to connect to it. You can find it in /etc/php/5.6/fpm/php.ini
(you can replace 5.6 with the version you are running).
answered Jul 30 '16 at 15:03
George DonevGeorge Donev
1011
1011
add a comment |
add a comment |
I had the same problem and adding the listen statement
listen 127.0.0.1;
worked for me.
Interestingly enough I have other server blocks that are running quite happily without this!
3
This has been answered and accepted already, three years ago.
– Sven♦
Nov 26 '14 at 23:13
add a comment |
I had the same problem and adding the listen statement
listen 127.0.0.1;
worked for me.
Interestingly enough I have other server blocks that are running quite happily without this!
3
This has been answered and accepted already, three years ago.
– Sven♦
Nov 26 '14 at 23:13
add a comment |
I had the same problem and adding the listen statement
listen 127.0.0.1;
worked for me.
Interestingly enough I have other server blocks that are running quite happily without this!
I had the same problem and adding the listen statement
listen 127.0.0.1;
worked for me.
Interestingly enough I have other server blocks that are running quite happily without this!
edited Nov 26 '14 at 23:11
Sven♦
87.2k10147199
87.2k10147199
answered Nov 26 '14 at 22:48
Rob GanlyRob Ganly
11
11
3
This has been answered and accepted already, three years ago.
– Sven♦
Nov 26 '14 at 23:13
add a comment |
3
This has been answered and accepted already, three years ago.
– Sven♦
Nov 26 '14 at 23:13
3
3
This has been answered and accepted already, three years ago.
– Sven♦
Nov 26 '14 at 23:13
This has been answered and accepted already, three years ago.
– Sven♦
Nov 26 '14 at 23:13
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f317393%2fconnect-failed-111-connection-refused-while-connecting-to-upstream%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
'Connection refused' means that backend does not listen to the port 9000 or its queue is filled up. This problem is related to the backend itsef. Are you able to telnet localhost 9000? You should also check your backend and php logs.
– Andrew
Oct 1 '11 at 9:17
Updated my post. I could not telnet to localhost 9000.
– MacMac
Oct 1 '11 at 10:48
The same error I was facing you, This enter link description here can help you
– Tripathi29
Nov 2 '15 at 13:53