Host Node JS On Hostinger
Last Updated 16 September 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.
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.
Prerequisites
Before proceeding, ensure you have:
- A Node JS app uploaded on Github.
- A Hostinger account with a VPS plan.
- Basic knowledge of SSH and Server management.
1. Get Hostinger VPS hosting plan
To host node js app we will use Hostinger VPS plan as we cannot host node js on shared hosting, 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
So now let's setup the VPS, to setup follow below steps:
- Login to your Hostinger account, go to VPS Section and click on Setup VPS.
- First, it will display the option select the location of your VPS, it is recommended choose the nearest server location to your audience.
- Next it will ask you to choose Operating System Type for your VPS, Select Plain OS as we don't want a control panel.
- Next 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.
- Now it will ask you to enter your vps name, a root password and a SSH key(optional). Make sure you create a strong password and store it in secure place.
- Also you can use a SSH keys authentication method for logging in to know more about it refer to this tutorial: how to setup ssh and use in vps
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.
- 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
sudo apt install git
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
node -v
npm -v
mkdir ~/apps/demo
cd ~/apps/demo
git clone enter-your-repo-url .
npm install
npm install -g pm2
pm2 start your_app.js
So we successfully hosted Node.js app on Hostinger. You can further optimize this deployment by installing Apache or Nginx web server
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?
Yes, to host a Node.js app on Hostinger, you need to purchase a VPS plan.
What operating system should I use for my VPS?
It is recommended to use Ubuntu 20.04 64-bit for your VPS.
What is the cost of hosting a Node.js app on Hostinger?
The basic VPS plan starts at $4.99 per month.
Can I host multiple Node.js apps on the same VPS?
Yes, you can host multiple apps by creating separate directories for each app and managing them with PM2.
About the author
I am Jarvis Silva, a tech enthusiast. I have 5 years of experience in website hosting and development, Now sharing all my knowledge related to web hosting and other various tech on the internet through Hostwizly.