3 free Node.js hosting services you should be using today (with step-by-step deployment examples)
Hosting Node.js applications is easy, finding a completely free Node.js hosting service that is reliable is not. In this post, we will discuss 3 hosting services where you can host your Node.js applications or API for free which you should start using now. We will also deploy a demo app step-by-step on each of these 3 platforms. I wished to have found more than 3 but finding even 3 was not very easy.
Table of contents #
- Free Node.js Hosting options
- Prerequisites
- Free Node.js hosting services
- Issues with these services
- Free Node.js hosting platforms to deploy your app
- Quick comparison of Free Node.js hosting services
- Other options for free Node.js hosting
- Conclusion
Free Node.js Hosting options #
This post is about services where you can host your Node.js application completely free, yes for $0 a month. Of course, when you don’t pay anything you will need to make some trade-offs. Still, this is not a list with just a couple of free options and a bulk of paid alternatives like the other posts I have seen and read.
I have tried all of the 3 services on my own and they work pretty well for demo and small-sized applications.
Needless to say, we would not use a free service to host a medium-sized or a production-level application. All of these 3 main services DO NOT ask for your credit card even for backup purposes so keep them inside your wallets.
I will include 3+ other services that ask for credit cards or have pretty inexpensive plans towards the end to make the list a bit more comprehensive.
Prerequisites #
All 3 of these services that we are going to look at in the next sections. Before we dive into actually deploying our Node.js applications below are some prerequisites:
- You have a GitHub account and know how to fork repositories
- Your application code is available on GitHub
- You are able to add third-party applications to your GitHub account.
Time to start revealing our free Node.js hosting services:
Free Node.js hosting services #
The free Node.js hosting services are Heroku (free tier), Vercel (hobby free forever plan), and Zeet. All these services can host your Node.js application for $0 a month a.k.a. absolutely and completely free. You don't even need to add a credit card for backup or safety reasons. But there are strings attached, as discussed next.
Issues with these services #
Heroku free dynos sleep if they are inactive for 30 minutes.
There is a workaround called Kaffeine that calls your Heroku service every 30 minutes.
Or you can use something like Cron-Job.org to ping your Heroku service every 20 minutes to keep it awake. Heroku has a maximum of 5 applications available on the free tier.
Vercel is an amazing service, where you could host both your backend API and frontend application in the same repository. It focuses more on the frontend side of things.
The downside is that Vercel uses serverless functions. It is like a great wrapper on top of AWS Lambda. It only allows personal GitHub repositories for free, not organizational ones.
With serverless functions, the issues of cold start and losing application state comes into the picture.
Zeet is another awesome service where neither the app sleeps if you don’t get requests for 30 minutes nor it is serverless.
The con here is you get only 1 app free but it gets 1 shared CPU and 1 GB of shared memory.
Well, that is still better than the above two options if you only have only one coding challenge to deploy.
Free Node.js hosting platforms to deploy your app #
Ok, let’s cut the rant and get to deploying a demo application. For this illustration I will use A node.js Express API that talks with a PostgreSQL database on ElephantSQL.
This is a simple quotes API and you can find the code open-source on Github. Time to see this app hosted for free on Heroku.
Heroku #
Heroku is a salesforce company and one of the first Platform-as-a-service (PaaS) companies that made it big, really big. It has been around since 2007, and it has evolved and adapted well to the changing technology landscape in the past 15 years. We can host multiple languages as Heroku Dynos and Node.js is definitely one of them.
Heroku even 11 years back in 2010 was more like throw me your app and I will run it for you, this was before Docker and containers were a thing.
Now in 2021, they have a host of services, and luckily the Free plan is still alive on their pricing page. Time to proceed to how you can deploy the demo app on Heroku:
Deploy Node.js Quotes API to Heroku #
You will need a free account on Heroku to get started. After you have registered, please follow the steps below to run your Node.js app on Heroku:
- Login to your Heroku account
- Go to: https://github.com/geshan/nodejs-posgresql
- Click on the “Deploy to Heroku” button
- On the Heroku “Create New App” page give the app a name like
nodejs-heroku-try
or something that is available - Then click “Deploy App”
- Wait for a minute or two and it will build and deploy the app like below:
- After that click the “View” button, you should see something like below:
- Add
/quotes
to the URL and you should see the quotes in JSON format as follows:
Wasn’t that easy, there you have the quotes API built with Node.js and Express running on the first free Node.js hosting platform: Heroku.
It did not run magically though, the settings were already present on the repo in the app.json file. This tells Heroku how to deploy the app. For a real-life app, we will need to set the correct environment variable mainly secrets like database credentials properly.
To make it better you can Fork the repository and connect Github as a deployment method for Heroku.
Furthermore, you can set up Pipelines to create staging and production environments in Heroku. You can also use the Heroku CLI for more control over your apps. I leave further exploration to you. Next, let’s look at how to deploy the same application on Vercel.
Vercel #
Vercel (previously known as Zeit) is a great place to deploy frontend apps. Being a layer on top of serverless functions it can also run some other languages and Node.js is included in that list. Amongst other good features, a very handy feature with Vercel is you get a unique URL for each pull request which makes testing that particular branch a breeze. They call this deploy preview.
Vercel Pricing is pretty straight forward. Personal projects run free and it integrates with GitHub, BitBucket, and GitLab.
Let's look at how we can deploy our Quotes API Node.js app on Vercel.
Deploy Node.js Quotes API on Vercel #
After you have registered with Vercel and are logged into Vercel, do the following steps:
- Visit https://github.com/geshan/nodejs-posgresql (you don’t even need to fork the repo)
- Click on the blue “Deploy” button
- Give it a name in the Vercel UI like below:
- And click "Continue"
- You can create your own repo on Github from the screen below:
- After that, select the root as the project’s source code, then click “Continue”
- Subsequently, click deploy in the next screen:
- It will build and deploy the app and you will see a screen like below:
- Now, click the “Visit” button, you should see something like the following:
- Add
/quotes
to the URL and you should see the quotes in a JSON format like below:
This is set up very well now, you should go to the app’s settings page if you want to tweak anything. You can add environment variables and do other things in the settings. You can even look at the function’s logs.
Each time you open a new pull request in that repository Vercel will give you a deploy preview URL which is very handy. You can see how it looks like below:
On merge to master/main branch, it will auto-deploy the code to the main URL. You can use the Vercel CLI for re-deployments, setting up environment variables, and a host of other things.
Both Heroku and Vercel have powerful CLI to make your life easier for deploying the apps and doing other things like having a look at the app logs from the CLI.
Next, let's look at how Zeet compares to Heroku and Vercel.
Zeet #
Zeet brands itself as the easiest way to deploy. It supports both code from Github or a public docker container. Zeet is not as popular as either Heroku or Vercel but it packs a punch with its simplicity quotient.
As Zeet doesn’t run serverless functions or sleep in 30 mins it looks like a promising option to host just one app for free.
As per its pricing page, we can run one project for free with limited and shared resources. Time to dig more into Zeet:
Update: Mar 2021 - Zeet has started to charge #
Recently Zeet has deprecated its free plan and started to charge $5 for the single shared VM it used to provide free. I would recommend using Qovery as an alternative to Zeet which has a great free plan.
Deploy Node.js Quotes API to Zeet #
Given you have registered on to Zeet with GitHub and you are logged into Zeet, follow the steps below:
- Fork the
https://github.com/geshan/nodejs-posgresql
repository to your GitHub account - Go to Zeet, click the green “+ New Project” button on the top right of Zeet
- Then click “GitHub” and click the green “Continue” button under the “Trial $0” option
- After that, click “Continue” besides the “Nodejs-posgresql” repo that you have just forked and then click “Deploy Now” as seen below:
- Subsequently, choose “Node.js 14” on “Build Method” and click “Save” as follows:
- Give it some time to build and deploy, after that, you will see something like below:
- If you click the green "Visit" button, it will not work now. There is one small config left. Click on “Settings” then click on the “Networking” link on the left then set the "Port" to be
3000
as seen below, after that click “Save” on the bottom right as seen below:
- This should redeploy the App, if you go back to the “Deployments” tap it should be deploying/deployed.
- Consequently, click the “Visit” button again you should see something like below:
- Next, add
/quotes
to the URL and you should see something similar to the following:
Like Vercel, Zeet also provides a deploy preview URL on each pull request. I have a feeling they wanted to compete Zeit with Zeet :), if you know what I mean. Below is a preview of how the deploy perview URL looks like as a comment in your pull reqeust:
Anyway if you want to deploy your own app you will need to delete this demo app and add your own app. Zeet only allows 1 free app. They have more demos in their GitHub account. Zeet does not have a CLI app which is good I suppose as it wants to keep things simple and clean.
There you have it, the same Node.js API deployed on all 3 free Node.js hosting services without even needing to reach your wallet for your credit card.
Quick comparison of Free Node.js hosting services #
Below is a quick comparison table for Heroku, Vercel, and Zeet.
Feature/Service | CPU | Memory | Sleeps on no activity? | Is FAAS/Serverless? | No. of apps? |
---|---|---|---|---|---|
Heroku | 1x | 512 MB | After 30 mins | No | 5 |
Vercel | N/A | 1 GB | No | Yes | Unlimited |
Zeet | 1 Shared | 1 GB Shared | No | No | 1 |
After that contrast, let’s look at some other options that are free but still ask for your credit card as a backup option that they can charge if you use more resources.
Other options for free Node.js hosting #
Some other services where you can host your Node.js application free/almost free but you need to put your credit card are as follows:
- Fly.io - Pretty good, it is like CDN for the backend. The free plan has 3 shared-CPU-1x VMs with 256 MB of RAM. Asks for a credit-card on registration.
- Google Cloud Run - You can host your Node.js app on Google Cloud Run as serverless containers. You can get up to 2 million requests per month free. But it will involve setting up Google Cloud Registry and other tools. Part of Google Cloud Platform which asks for a credit card on registration.
- Openode.io - If you have an open-source project you can ask them for a free plan. The cheapest plan with 50MB of memory is just $0.75 a month.
- Glitch - Glitch can host one of your Node.js Apps for free. It is better used to code collaboratively than host a Node.js app or API.
You can host your Node.js App on all 3 of the big cloud providers AWS, Azure, and GCP and/or their function as a service (FAAS) serverless options or even on free-forever VM. But, they will ask for your credit-card.
You can even explore other cloud providers like IBM Cloud or Alibaba to host your Node.js app for $0 a month. I will leave the digging deeper part for you.
If you are looking for windows hosting, this Windows VPS Hosting Comparison is great.
Conclusion #
Hosting a small test project with Node.js should not be a hassle.
You should be able to do it easily with any of the above 3 services that give it absolutely free.
You can also use the other services that give it for free but ask you to put down your credit card number. The choice is yours!