sandaemax sandaemax - 10 months ago 59
Node.js Question

Why nodejs http request doesn't work when accessing a local served express app?

I have an express REST API app running on 8082. Then I'm trying to do a call from my another app using request:{
url: 'http://localhost:8082/test',
method: 'POST',
json: {
code: 'Hello'
}, (err, res, body) => {

But I'm getting a
502 Bad Gateway

<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>

Does it look like it's looking into Nginx but not to expressjs?

How can I force it to look into my running app?

Answer Source

Check your other app code for the right port, or change the port if nginx is listening on that port.