Question

NodeJS app is not accessible on ip/domain.

I have a Node.js application that is running and accessible from other VPS. However, I am unable to run the application on DigitalOcean.The code is the same and I am using the same method to install. though npm and node versions are also the same. The applications were installed successfully in the Digitalocean droplet but isn’t accessible on IP. I have tried both new droplets and NodeJS app. On the new droplet the ip simply shows “refused to connect” and on nodejs it shows “502 bad gateway”. p.s NodeJS app is running and online but still isn’t accessible via ip/domain


Submit an answer


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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
October 2, 2023

Hi there,

This sounds like an issue with your Nginx configuration. As you’re using a proxy like Nginx and encountering a “502 Bad Gateway” error, I could suggest the following:

  • Check the error logs for Nginx using sudo tail -n 50 /var/log/nginx/error.log. This should provide more detailed information about the 502 error.
  • Ensure your proxy is correctly set up to forward requests to the correct port and address where your Node.js app is running.

If the port in the Nginx configuration does not match the port that your Node.js service is running on you would get the 502 error.

You could use the netstat -plant command to check what port your app is listening on.

Let me know how it goes!

Best,

Bobby

KFSys
Site Moderator
Site Moderator badge
October 2, 2023

Heya @floatingbluegreenseal,

It seems you are using Nginx as a reverse proxy, is that correct? Can you share your nginx configuration that is related to your App?

Additionally, have you allowed the IPs to be accessible through your firewall? Can you type in

ufw status

And let me know the output.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel