502 Bad Gateway nginx/1.10.3 error with NodeJS (Debian 9)Proxy HTTPS requests to a HTTP backend with NGINXnginx redirect issue with upstream configurationNginx subversion commit failureYet another 502 error with NginXNginx/Apache: set HSTS only if X-Forwarded-Proto is httpsIntermittent 502: bad gateway on nginx + shiny server502 bad gateway nginx and apache serversConfigure NGINX : How to handle 500 Error on upstream itself, While Nginx handle other 5xx errorsWhy Nginx calls for invalid certificate in non-existent subdomains just to redirect to 404?Nginx reverse proxy to many local servers + webserver duty
Mechanism of Acid Hydrolysis
Tikz-cd diagram arrow passing under a node - not crossing it
Do empty drive bays need to be filled?
What would be the way to say "just saying" in German? (Not the literal translation)
Can there be absolute velocity?
A Salute to Poetry
A life of PhD: is it feasible?
Rail-to-rail op-amp only reaches 90% of VCC, works sometimes, not everytime
Part of my house is inexplicably gone
Use 1 9 6 2 in this order to make 75
If someone intimidates another person, does the person affected gain the Frightened condition?
Command of files and size
Converting from CMYK to RGB (to work with it), then back to CMYK
What should I be wary of when insurer is taking a lot of time to decide whether car is repairable or a total loss?
Why is the length of the Kelvin unit of temperature equal to that of the Celsius unit?
Does putting salt first make it easier for attacker to bruteforce the hash?
Generate certain list from two lists
Oil draining out shortly after turbo hose detached/broke
How durable are silver inlays on a blade?
How many sets of dice do I need for D&D?
Three questions
Does a (nice) centerless group always have a centerless profinite completion?
Transfer custom ringtones to iPhone using a computer running Linux
bash vs. zsh: What are the practical differences?
502 Bad Gateway nginx/1.10.3 error with NodeJS (Debian 9)
Proxy HTTPS requests to a HTTP backend with NGINXnginx redirect issue with upstream configurationNginx subversion commit failureYet another 502 error with NginXNginx/Apache: set HSTS only if X-Forwarded-Proto is httpsIntermittent 502: bad gateway on nginx + shiny server502 bad gateway nginx and apache serversConfigure NGINX : How to handle 500 Error on upstream itself, While Nginx handle other 5xx errorsWhy Nginx calls for invalid certificate in non-existent subdomains just to redirect to 404?Nginx reverse proxy to many local servers + webserver duty
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
For a few days I have a server where I run successfully a few Web applications developed in NodeJS.
Everything worked fine until suddenly the browser started to show the error 502 Bad Gateway nginx/1.10.3 when trying to access to the website. I have not made any changes that could create this type of error.
Looking for information on the web, it seems that this error is related to the way Nginx directs the request to the port of my application. I have reviewed the configuration in my/etc/nginx/sites-available/default and everything seems correct. This is an excerpt from my configuration:
# --------------------------
# WEBSITE 1 - www.mywebsite.com
# --------------------------
server
listen 80;
if ($host = mywebsite.com)
return 301 https://www.mywebsite.com$request_uri;
if ($host = www.mywebsite.com)
return 301 https://www.mywebsite.com$request_uri;
server_name www.mywebsite.com mywebsite.com;
location /
proxy_pass "http://127.0.0.1:3000";
server
listen 443 ssl;
if ($host = mywebsite.com)
return 301 https://www.mywebsite.com$request_uri;
server_name www.mywebsite.com mywebsite.com;
location /
proxy_pass "http://127.0.0.1:3000";
# LetsEncrypt Certificates
ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
# --------------------------
# WEBSITE 2 - www.mywebsite2.com
# --------------------------
server
listen 80;
if ($host = mywebsite2.com)
return 301 https://www.mywebsite2.com$request_uri;
if ($host = www.mywebsite2.com)
return 301 https://www.mywebsite2.com$request_uri;
server_name www.mywebsite2.com mywebsite2.com;
location /
proxy_pass "http://127.0.0.1:3001";
server
listen 443 ssl;
if ($host = mywebsite2.com)
return 301 https://www.mywebsite2.com$request_uri;
server_name www.mywebsite2.com mywebsite2.com;
location /
proxy_pass "http://127.0.0.1:3001";
# [...] More LetsEncrypt Certificates, and more websites [...]
Also, I looked at the nginx error.log file and I can see that this line is written every time the website is accessed since this error happened:
[error] connect() failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: www.mywebsite.com, request: "GET /aCustomUrl HTTP/1.1", upstream: "http://127.0.0.1:3000/aCustomUrl", host: "www.mywebsite.com"
Do you have any hint what can be happening? The config seems OK to me and it worked several days before successfully. I tried restarting the server, but it does not help...
Thanks all.
nginx node.js
add a comment |
For a few days I have a server where I run successfully a few Web applications developed in NodeJS.
Everything worked fine until suddenly the browser started to show the error 502 Bad Gateway nginx/1.10.3 when trying to access to the website. I have not made any changes that could create this type of error.
Looking for information on the web, it seems that this error is related to the way Nginx directs the request to the port of my application. I have reviewed the configuration in my/etc/nginx/sites-available/default and everything seems correct. This is an excerpt from my configuration:
# --------------------------
# WEBSITE 1 - www.mywebsite.com
# --------------------------
server
listen 80;
if ($host = mywebsite.com)
return 301 https://www.mywebsite.com$request_uri;
if ($host = www.mywebsite.com)
return 301 https://www.mywebsite.com$request_uri;
server_name www.mywebsite.com mywebsite.com;
location /
proxy_pass "http://127.0.0.1:3000";
server
listen 443 ssl;
if ($host = mywebsite.com)
return 301 https://www.mywebsite.com$request_uri;
server_name www.mywebsite.com mywebsite.com;
location /
proxy_pass "http://127.0.0.1:3000";
# LetsEncrypt Certificates
ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
# --------------------------
# WEBSITE 2 - www.mywebsite2.com
# --------------------------
server
listen 80;
if ($host = mywebsite2.com)
return 301 https://www.mywebsite2.com$request_uri;
if ($host = www.mywebsite2.com)
return 301 https://www.mywebsite2.com$request_uri;
server_name www.mywebsite2.com mywebsite2.com;
location /
proxy_pass "http://127.0.0.1:3001";
server
listen 443 ssl;
if ($host = mywebsite2.com)
return 301 https://www.mywebsite2.com$request_uri;
server_name www.mywebsite2.com mywebsite2.com;
location /
proxy_pass "http://127.0.0.1:3001";
# [...] More LetsEncrypt Certificates, and more websites [...]
Also, I looked at the nginx error.log file and I can see that this line is written every time the website is accessed since this error happened:
[error] connect() failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: www.mywebsite.com, request: "GET /aCustomUrl HTTP/1.1", upstream: "http://127.0.0.1:3000/aCustomUrl", host: "www.mywebsite.com"
Do you have any hint what can be happening? The config seems OK to me and it worked several days before successfully. I tried restarting the server, but it does not help...
Thanks all.
nginx node.js
add a comment |
For a few days I have a server where I run successfully a few Web applications developed in NodeJS.
Everything worked fine until suddenly the browser started to show the error 502 Bad Gateway nginx/1.10.3 when trying to access to the website. I have not made any changes that could create this type of error.
Looking for information on the web, it seems that this error is related to the way Nginx directs the request to the port of my application. I have reviewed the configuration in my/etc/nginx/sites-available/default and everything seems correct. This is an excerpt from my configuration:
# --------------------------
# WEBSITE 1 - www.mywebsite.com
# --------------------------
server
listen 80;
if ($host = mywebsite.com)
return 301 https://www.mywebsite.com$request_uri;
if ($host = www.mywebsite.com)
return 301 https://www.mywebsite.com$request_uri;
server_name www.mywebsite.com mywebsite.com;
location /
proxy_pass "http://127.0.0.1:3000";
server
listen 443 ssl;
if ($host = mywebsite.com)
return 301 https://www.mywebsite.com$request_uri;
server_name www.mywebsite.com mywebsite.com;
location /
proxy_pass "http://127.0.0.1:3000";
# LetsEncrypt Certificates
ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
# --------------------------
# WEBSITE 2 - www.mywebsite2.com
# --------------------------
server
listen 80;
if ($host = mywebsite2.com)
return 301 https://www.mywebsite2.com$request_uri;
if ($host = www.mywebsite2.com)
return 301 https://www.mywebsite2.com$request_uri;
server_name www.mywebsite2.com mywebsite2.com;
location /
proxy_pass "http://127.0.0.1:3001";
server
listen 443 ssl;
if ($host = mywebsite2.com)
return 301 https://www.mywebsite2.com$request_uri;
server_name www.mywebsite2.com mywebsite2.com;
location /
proxy_pass "http://127.0.0.1:3001";
# [...] More LetsEncrypt Certificates, and more websites [...]
Also, I looked at the nginx error.log file and I can see that this line is written every time the website is accessed since this error happened:
[error] connect() failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: www.mywebsite.com, request: "GET /aCustomUrl HTTP/1.1", upstream: "http://127.0.0.1:3000/aCustomUrl", host: "www.mywebsite.com"
Do you have any hint what can be happening? The config seems OK to me and it worked several days before successfully. I tried restarting the server, but it does not help...
Thanks all.
nginx node.js
For a few days I have a server where I run successfully a few Web applications developed in NodeJS.
Everything worked fine until suddenly the browser started to show the error 502 Bad Gateway nginx/1.10.3 when trying to access to the website. I have not made any changes that could create this type of error.
Looking for information on the web, it seems that this error is related to the way Nginx directs the request to the port of my application. I have reviewed the configuration in my/etc/nginx/sites-available/default and everything seems correct. This is an excerpt from my configuration:
# --------------------------
# WEBSITE 1 - www.mywebsite.com
# --------------------------
server
listen 80;
if ($host = mywebsite.com)
return 301 https://www.mywebsite.com$request_uri;
if ($host = www.mywebsite.com)
return 301 https://www.mywebsite.com$request_uri;
server_name www.mywebsite.com mywebsite.com;
location /
proxy_pass "http://127.0.0.1:3000";
server
listen 443 ssl;
if ($host = mywebsite.com)
return 301 https://www.mywebsite.com$request_uri;
server_name www.mywebsite.com mywebsite.com;
location /
proxy_pass "http://127.0.0.1:3000";
# LetsEncrypt Certificates
ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
# --------------------------
# WEBSITE 2 - www.mywebsite2.com
# --------------------------
server
listen 80;
if ($host = mywebsite2.com)
return 301 https://www.mywebsite2.com$request_uri;
if ($host = www.mywebsite2.com)
return 301 https://www.mywebsite2.com$request_uri;
server_name www.mywebsite2.com mywebsite2.com;
location /
proxy_pass "http://127.0.0.1:3001";
server
listen 443 ssl;
if ($host = mywebsite2.com)
return 301 https://www.mywebsite2.com$request_uri;
server_name www.mywebsite2.com mywebsite2.com;
location /
proxy_pass "http://127.0.0.1:3001";
# [...] More LetsEncrypt Certificates, and more websites [...]
Also, I looked at the nginx error.log file and I can see that this line is written every time the website is accessed since this error happened:
[error] connect() failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: www.mywebsite.com, request: "GET /aCustomUrl HTTP/1.1", upstream: "http://127.0.0.1:3000/aCustomUrl", host: "www.mywebsite.com"
Do you have any hint what can be happening? The config seems OK to me and it worked several days before successfully. I tried restarting the server, but it does not help...
Thanks all.
nginx node.js
nginx node.js
asked May 27 at 8:45
Óscar GiménezÓscar Giménez
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Is your app directly accessible through http://127.0.0.1:3000?
Try:
curl http://127.0.0.1:3000
Does it give a response?
If not, 502 Bad Gateway error could mean your nodejs process is crashing. Maybe a package that needs to rebuilt. Like sqlite3. Have you recently upgraded nodejs?
No, it is not accessible:curl: (7) Failed to connect to 127.0.0.1 port 3021: Connection refused.
I did alsonpm install
of the app, just in case that a package was wrong, but the issue keeps existing.
– Óscar Giménez
May 27 at 12:23
How are you running the nodejs application? Are you using something like pm2?
– Expenzor
May 28 at 4:42
Yes, I'm sure that the app is running (I use pm2). Finally, I opted to reinstall my entire VPS, setting the exact same config file as above and now all my websites are running again... Thanks for your interest @Expenzor
– Óscar Giménez
May 28 at 5:45
Sorry I couldn't be of much help. Glad you could fix it, even though it needed such drastic measures.
– Expenzor
May 28 at 18:12
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%2f968944%2f502-bad-gateway-nginx-1-10-3-error-with-nodejs-debian-9%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is your app directly accessible through http://127.0.0.1:3000?
Try:
curl http://127.0.0.1:3000
Does it give a response?
If not, 502 Bad Gateway error could mean your nodejs process is crashing. Maybe a package that needs to rebuilt. Like sqlite3. Have you recently upgraded nodejs?
No, it is not accessible:curl: (7) Failed to connect to 127.0.0.1 port 3021: Connection refused.
I did alsonpm install
of the app, just in case that a package was wrong, but the issue keeps existing.
– Óscar Giménez
May 27 at 12:23
How are you running the nodejs application? Are you using something like pm2?
– Expenzor
May 28 at 4:42
Yes, I'm sure that the app is running (I use pm2). Finally, I opted to reinstall my entire VPS, setting the exact same config file as above and now all my websites are running again... Thanks for your interest @Expenzor
– Óscar Giménez
May 28 at 5:45
Sorry I couldn't be of much help. Glad you could fix it, even though it needed such drastic measures.
– Expenzor
May 28 at 18:12
add a comment |
Is your app directly accessible through http://127.0.0.1:3000?
Try:
curl http://127.0.0.1:3000
Does it give a response?
If not, 502 Bad Gateway error could mean your nodejs process is crashing. Maybe a package that needs to rebuilt. Like sqlite3. Have you recently upgraded nodejs?
No, it is not accessible:curl: (7) Failed to connect to 127.0.0.1 port 3021: Connection refused.
I did alsonpm install
of the app, just in case that a package was wrong, but the issue keeps existing.
– Óscar Giménez
May 27 at 12:23
How are you running the nodejs application? Are you using something like pm2?
– Expenzor
May 28 at 4:42
Yes, I'm sure that the app is running (I use pm2). Finally, I opted to reinstall my entire VPS, setting the exact same config file as above and now all my websites are running again... Thanks for your interest @Expenzor
– Óscar Giménez
May 28 at 5:45
Sorry I couldn't be of much help. Glad you could fix it, even though it needed such drastic measures.
– Expenzor
May 28 at 18:12
add a comment |
Is your app directly accessible through http://127.0.0.1:3000?
Try:
curl http://127.0.0.1:3000
Does it give a response?
If not, 502 Bad Gateway error could mean your nodejs process is crashing. Maybe a package that needs to rebuilt. Like sqlite3. Have you recently upgraded nodejs?
Is your app directly accessible through http://127.0.0.1:3000?
Try:
curl http://127.0.0.1:3000
Does it give a response?
If not, 502 Bad Gateway error could mean your nodejs process is crashing. Maybe a package that needs to rebuilt. Like sqlite3. Have you recently upgraded nodejs?
answered May 27 at 10:51
ExpenzorExpenzor
11
11
No, it is not accessible:curl: (7) Failed to connect to 127.0.0.1 port 3021: Connection refused.
I did alsonpm install
of the app, just in case that a package was wrong, but the issue keeps existing.
– Óscar Giménez
May 27 at 12:23
How are you running the nodejs application? Are you using something like pm2?
– Expenzor
May 28 at 4:42
Yes, I'm sure that the app is running (I use pm2). Finally, I opted to reinstall my entire VPS, setting the exact same config file as above and now all my websites are running again... Thanks for your interest @Expenzor
– Óscar Giménez
May 28 at 5:45
Sorry I couldn't be of much help. Glad you could fix it, even though it needed such drastic measures.
– Expenzor
May 28 at 18:12
add a comment |
No, it is not accessible:curl: (7) Failed to connect to 127.0.0.1 port 3021: Connection refused.
I did alsonpm install
of the app, just in case that a package was wrong, but the issue keeps existing.
– Óscar Giménez
May 27 at 12:23
How are you running the nodejs application? Are you using something like pm2?
– Expenzor
May 28 at 4:42
Yes, I'm sure that the app is running (I use pm2). Finally, I opted to reinstall my entire VPS, setting the exact same config file as above and now all my websites are running again... Thanks for your interest @Expenzor
– Óscar Giménez
May 28 at 5:45
Sorry I couldn't be of much help. Glad you could fix it, even though it needed such drastic measures.
– Expenzor
May 28 at 18:12
No, it is not accessible:
curl: (7) Failed to connect to 127.0.0.1 port 3021: Connection refused.
I did also npm install
of the app, just in case that a package was wrong, but the issue keeps existing.– Óscar Giménez
May 27 at 12:23
No, it is not accessible:
curl: (7) Failed to connect to 127.0.0.1 port 3021: Connection refused.
I did also npm install
of the app, just in case that a package was wrong, but the issue keeps existing.– Óscar Giménez
May 27 at 12:23
How are you running the nodejs application? Are you using something like pm2?
– Expenzor
May 28 at 4:42
How are you running the nodejs application? Are you using something like pm2?
– Expenzor
May 28 at 4:42
Yes, I'm sure that the app is running (I use pm2). Finally, I opted to reinstall my entire VPS, setting the exact same config file as above and now all my websites are running again... Thanks for your interest @Expenzor
– Óscar Giménez
May 28 at 5:45
Yes, I'm sure that the app is running (I use pm2). Finally, I opted to reinstall my entire VPS, setting the exact same config file as above and now all my websites are running again... Thanks for your interest @Expenzor
– Óscar Giménez
May 28 at 5:45
Sorry I couldn't be of much help. Glad you could fix it, even though it needed such drastic measures.
– Expenzor
May 28 at 18:12
Sorry I couldn't be of much help. Glad you could fix it, even though it needed such drastic measures.
– Expenzor
May 28 at 18:12
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%2f968944%2f502-bad-gateway-nginx-1-10-3-error-with-nodejs-debian-9%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