By roccoden91
If I run on my droplet ubuntu 20.04 with nginx a simple test nodejs server, it works:
const http = require('http');
const hostname = 'localhost';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World!\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
but when I try to update it with my more complex node server I get back ’ 502 Bad Gateway '.
error.log:
2021/03/29 10:49:21 [error] 1430#1430: *1352 connect() failed (111: Connection refused) while connecting to upstream, client: 2.45.152.97, server: ferramentadenicolo.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "www.ferramentadenicolo.com"
Trying to understand what give me back this error, I noticed that just adding to the simple test a string like:
const api = require('./routes/api');
it returns me the 502
Some advice please? I’m really new about deploying a server and I don’t know how to proceed. THX
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hey, @roccoden91 have you checked your port configuration in the “complex node server” setup and made sure that it is matching your Nginx port forwarding?
Post your configs here, so we can take a look and give you some feedback.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.