How to install node.js on server?

Posted June 14, 2020 1.2k views


I am really new to servers and I stucked on somewhere. I looked for this for hours but i could not find the solution.

I have a simple node.js app for a chat app. I created a CentOS droplet and installed node.js, NPM, and pm2 in it. My sockets were running just fine but I could not be able to POST some data to my node.js app. What should I do to install the node.js on a droplet properly? Why I could not be able to POST data? It seemed weird to me because my app was running, I was able to use de sockets but it was not receiving POST data.

Also I tried the node.js on Ubuntu from Marketplace but I coulnd find out how to use it, I couldn’t even figure out how to run my app. And by the way, my app is running all fine in my local Windows.

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.

Submit an Answer
1 answer

Hi @cemMantaRay,

Firstly, I would recommend checking out this article right here :

You’ve most probably checked it however in case you haven’t give it a try.

Now to the problem you’ve mentioned. Are you sure you’ve used the proper port? Usually, when you open a website on the browser it either uses 80 or 443 by default. As far as I know usually nodejs apps use different ports. Maybe that’s your issue right here.

In order to check which port uses your nodejs app, you can check or configuration file or once you’ve started nodejs, type in the following command on your droplet

netstat -tulpen

This will show which ports are being used. Now that you know the port, try to POST data to your app.


by Brian Boucheron
In this guide, we will show you three different ways of getting Node.js installed on a CentOS 8 server: using `dnf` to install the `nodejs` package from CentOS's default AppStream repository; installing `nvm`, the Node Version Manager, and using it to install and manage multiple versions of `node`; compiling and installing `node` from source.
  • Hi,

    When I go this way, I can’t reach to my server even. I think there is a problem with making the server reachable to the internet but I can’t find out.

    • Hmm, that’s strange. Have you made any changes to the networking side?

      Additionally, if you use your DigitalOcean console, can you SSH to your droplet and try to restart your network

      service network restart
      • Hi again,

        Thank you for your interest, I solved my problem by using the node.js installation on Ubuntu from marketplace. It works just fine now, I think I was doing something wrong with the Apache.

        • I’m glad to hear you managed to get it working even if on another droplet!

          As for Apache, it’s possible Apache was taking the ports NodeJS needed to.