i am an student who is working on a nodejs + nginx project taht i didn't start, so im not sure what is going on.... when i try accessing to my website, i am recibing a 502 Bad Gateway nginx/1.12.2 error.
i have been trying to solve it with the answers of other similar question but the problem is still there, i think there is something wrong with the configuration, but im not sure what it is.
the nginx.conf file is as follow
#!/usr/bin/env node
'use strict';
/**
* Module dependencies.
*/
//var http = require('http');
var app = require('../app/app');
var config = require('../config/config');
/**
* Get port from environment and store in Express.
*/
process.env.PORT = config.port;
var port = normalizePort(process.env.PORT);
//app.set('port', port);
app.listen(port , function () {
console.log('App listening on port ' + process.env.PORT);
});
/**
* Create HTTP server.
*/
//var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
//server.listen(port);
//server.on('error', onError);
//server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
}
/**
* Event listener for HTTP server "error" event.
*/
/* function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
} */
/**
* Event listener for HTTP server "listening" event.
*/
/* function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
console.log('Express server listening on port: %d, in %s mode',
app.get('port'), app.get('env'));
} */
also i have already checked the logs
2018/11/26 09:32:14 [error] 974#0: *7094 connect() failed (111: Connection
refused) while connecting to upstream, client: 189.183.151.200, server:
mexcx, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5001/", host:
"67.227.198.57"
hope you can help me on understanding what is going on, cause at the beginig it was working just fine, i was doing some changes on the code, i restart the server and i got the problem