Hostwizly

Host Node JS On Hostinger

Last Updated 18 June 2024 by Jarvis Silva

Looking for a tutorial on how to host your node js app on Hostinger then you are at the right place, In this tutorial I will show you how to host node js on Hostinger.

Prerequisites

  • A Node.js app uploaded on GitHub
  • A Hostinger account with a VPS plan
  • Basic knowledge of SSH and server management

Node JS is a open source server side javascript runitime environment which allows us to create robust backend for websites. Hosting your Node.js app on Hostinger is reliable and cost-effective, ensuring your app runs smoothly and efficiently. So let's see how to host it.

1. Get Hostinger VPS hosting plan

As I have said we will use the VPS plan at Hostinger to host our node js app so you need to purchase their VPS hosting plan, their basic VPS plan starts at 4.99$ per month which is quite cheap compared to other hosts.

Use this Special Hostinger discount link and get around 40-60% discount on VPS plans of Hostinger.

You can choose any of the VPS plan I will recommend to go with KVM 2 VPS plan as it has more resources you can also start with KVM 1 plan if you are just starting out or trying it so complete the registration and payment process let's go to the next step.

2. Setup VPS on Hostinger

Now we got the VPS from Hostinger we need to setup so upon login to your hostinger account you will be asked to setup your VPS if not asked go the VPS section and click on setup VPS and follow the below steps to setup vps on Hostinger:

  • First it will ask you to select the location of your VPS, choose the nearest server location to your audience.
  • Now it will ask you to choose what type of ui you want for your VPS there will be 3 options as you can look from below image choose Plain OS
  • Hostinger vps operating system selection
  • Now it will ask you to choose the os you want to install on your VPS click on I want to choose a different operating system and it will display multiple OS with different version select the latest ubuntu 20.04 64 bit OS in the future it might change.
  • Hostinger vps ubuntu os selection
  • Now it will ask you to enter your vps name, a root password and a ssh key(optional). Password and ssh are ways for you to login to your VPS so make sure to enter a strong password and remember it as we will require it later for logging into our server.
  • Also you can use a ssh for logging in to know more about it refer to this tutorial: how to setup ssh and use in vps
  • Hostinger vps details

After this your VPS setup will be completed, if you check in your Hostinger panel it will show VPS running, You will get a dedicated IP address for your server which you can use to access your site or you can connect a custom domain.

Also Read: How to connect custom domain in Hostinger vps.

So we have completed our VPS setup, now we need to ssh into our VPS and install node js on it so let's see how to do it.

3. Install and run Node JS On VPS

Now we need to install Node js on our VPS server as it is required for running node js application so follow the steps below to install node js:

  • Go to Putty website and download the putty software it will allow you to login into server, after installing putty open it and enter the ip address of your vps in the putty hostname column and click open.
  • Putty Connection
  • It will open a terminal where it will ask you to enter username mostly it is root and the password which you created at your VPS setup, If you have used SSH keys then it will automatically detect and login to your server.
  • Now you should have access to your server, now you can write commands which will get executed on your server so first run the below command it will update your apt repository.
  • sudo apt update
  • Next run this it will install git
  • sudo apt install git
  • Now we will install node js so execute all the below command line by line
  • curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
    sudo apt install -y nodejs
  • Use below commands to check if node and npm are installed, If installed it will display their versions
  • node -v
    npm -v
  • Now let's create a new directory for our node js project and import it from github to do that use below commands:
  • mkdir ~/apps/demo
  • This command will make a new directory inside apps folder called demo you can name your project name
  • cd ~/apps/demo
  • it change the working directory to the directory we created
  • git clone enter-your-repo-url .
  • it will get our node js code from github to our server inside the apps/demo folder.
  • npm install
  • Above command will install all the node_modules for the project
  • npm install -g pm2
  • Now to run our node js app we need to install a library called pm2 it is like nodemon in node js so install it by using above command:
  • pm2 start your_app.js
  • Now run the above command to start your node js app on the port specified in your server file, you can view your node js app at your ip-address:port in the browser.

That’s it for this article! We have successfully hosted our Node.js app on Hostinger. You can further optimize this deployment by installing Apache or Nginx as a reverse proxy.

Also Read: Host next js on Hostinger

I hope you found this tutorial helpful and useful do share it with someone who might need it. Thank you for reading, Have a nice day 😊

Frequently Asked Questions

Do I need a VPS to host a Node.js app on Hostinger?

What operating system should I use for my VPS?

What is the cost of hosting a Node.js app on Hostinger?

Can I host multiple Node.js apps on the same VPS?

About the author

I am Jarvis Silva, a tech-savvy individual. I have 5 years of experience in website hosting and development, Now sharing all my knowledge related to web hosting and other various technologies on the internet through Hostwizly.