3 services to deploy your Node.js app for free
Wouldn’t you like to move your application out of your local development environment and put it in a publicly accessible URL? Still, finding a good (and free) service to deploy your Node.js application is not that easy.
In this tutorial, we will see how to deploy a Node.js API built with Express.js and MySQL to three different services. We will use the API app for programming languages that I built for my previous post on Node.js and MySQL.
All the services listed in this post are absolutely free, and the best part that is you don’t need to reach for your credit card — it will not be required at all. Just a reminder, though: when we don’t pay anything, there will be some trade-offs to make.
As mentioned above, we will be using the Programming Languages API, which is connected with MySQL on freeDB.tech. Before continuing, however, make sure:
- You have a GitHub account and know the basics of Git/GitHub like forking a repository
- You are able to add third-party applications to your GitHub account for authentication and other purposes
Let’s get cracking! To proceed further, please fork this GitHub repository as we will use this as the example.
Qovery bills itself as “the simplest way to deploy your full-stack apps.” You will need to dockerize your Node.js app for it to be easily deployed to Qovery, so go ahead and follow this tutorial for Node.js and Docker if your app is not already dockerized.
The Qovery UI is intuitive and very useful. We will get started by registering on Qovery. Go to the login/signup page and click the Sign in with GitHub button. After you authorize Qovery in Github, you should be logged in to the Qovery console. After you’ve logged, in click the Create a new project button in the top left:
Consequently, we will see the following screen:
Select QoveryCommunity as the organization and type in programming-languages-api in the Project Name field. Click Create, and we will see the next screen:
Subsequently, click Go to project. You should see something similar to the page below:
On this page, click Create an application.
Then click I have an application.
Now select Connect to GitHub and choose the repo programming-languages-api that we forked earlier.
After that, check the name of the application (you can change it if you want) and hit Next.
On the database selection screen, hit Next without selecting any database since our MySQL database is already hosted and configured on a different service.
Finally, hit Deploy and wait for some time for the app to be ready.
Next, click the “Go to project” button.
Wait for some more time for the app to be deployed. You’ll see the status change to running, like below:
Click the Open link to see our app running:
We can add /programming-languages to the URL to see the list of our programming languages served by the GET API as follows:
Great! Our app is running on Qovery. In addition to easy deployment, Qovery also provides other great features, like an environment and URL for each branch. For more features, have a look at the Qovery docs.
Vercel, formerly known as Zeit, acts as a layer on top of AWS Lambda to run your applications. It is a serverless platform that can run a variety of things with a stronger focus on frontend. Fortunately, Node.js is one of the official runtimes on Vercel. Our regular Node.js Express API can run on Vercel with a well-configured vercel.json file. Let’s see how:
Go to the Vercel signup page and click on Continue with GitHub. After you have authenticated, click on New Project:
You’ll see the screen below:
In the list of your GitHub repositories, search for programming and find the programming-languages-api repo, then click Import.
Consequently, click Select on your personal account — note that only personal accounts are free on Vercel.
After that click, Continue to confirm the root is the base folder, as above.
In the above screen, select Other as the framework and click Deploy. It will take some time to build the project:
Then you will see the congratulations page to visit the deployed project:
When you click Visit, you’ll see something like the below:
To check the database connection, we can add /programming-languages to view the following output:
Hurray! Our app is running on Vercel now. Please be careful of the vercel.json file in the repo — that config is required for Vercel to run the Node.js build for our project.
Heroku is a pioneer in the platform-as-a-service market. It started out as a Ruby deployment service and has expanded to support languages like Node.js, Python, and PHP, to name a few.
Let’s proceed to deploy our application to Heroku. First, you will need to sign up:
Then log in to Heroku.
Over 200k developers use LogRocket to create better digital experiences
On the dashboard page, click on New and then Create new app, as above.
After that, type in a name for the app, like programming-languages-api in the above case. You might need to type in something different and available. Consequently, hit the “Create app” button.
On the above screen, click GitHub and select Connect beside the programming-languages-api repo you had forked in the first step.
After that, scroll down and click Deploy Branch for the master branch.
We will see the build, deployment logs, and a success message, like below:
Click on View to see an output like below:
Next, we can add /programming-languages to the URL to see that the app is able to connect to the database and render the rows correctly:
Yay! Our app is working fine on Heroku, too. Another tip is to turn on the Enable Automatic Deploys for your master/main branch. This means each change to the main branch will be automatically deployed.
You can find the Enable Automatic Deploy button above the Manual deploy section, as seen below:
One issue with the Heroku free plan is that the dyno sleeps after 30 minutes of inactivity. A workaround is to use Kaffeine to keep your apps awake even after 30 minutes of no requests hitting it.
Other options to consider
Those were the three amazing services that let us deploy a Node.js application for no cost at all, with no need to enter our credit card number. Of course, there are other services with which you could potentially run your Node.js app for no cost, but you will need to enter your billing information.
Here are some options I have tried:
: part of the Google Cloud platform that runs serverless containers. You could get up to 2 million requests per month for free : a CDN-as-backend kind of concept. Deploy your app servers close to your users. You could run three small VMs for free : free only for open source projects. but the most affordable plan is $0.75 per month with 50 MB memory
If you are comfortable putting down your credit card, any of the above options work in a pinch.
More great articles from LogRocket:
- Don’t miss a moment with The Replay, a curated newsletter from LogRocket how LogRocket’s Galileo cuts through the noise to proactively resolve issues in your app
- Use React’s useEffect to optimize your application’s performance
- Switch between multiple versions of Node your React app with AnimXYZ , a new framework for building binaries
- Compare NestJS vs. Express.js
All the above free services have a command line tool, too. If you are more comfortable with the CLI, you can give that a try as well.
The next good step would be to try mapping custom domains to your apps where applicable. It would be good to look at deployment logs and application logs on the mentioned services.
Till next time, happy deploying!
Deploying a Node-based web app or website is the easy part. Making sure your Node instance continues to serve resources to your app is where things get tougher. If you’re interested in ensuring requests to the backend or third party services are successful, try LogRocket. https://logrocket.com/signup/
LogRocket is like a DVR for web and mobile apps, recording literally everything that happens while a user interacts with your app. Instead of guessing why problems happen, you can aggregate and report on problematic network requests to quickly understand the root cause.
LogRocket instruments your app to record baseline performance timings such as page load time, time to first byte, slow network requests, and also logs Redux, NgRx, and Vuex actions/state. Start monitoring for free.
Geshan Manandhar Follow Geshan is a seasoned software engineer with more than a decade of software engineering experience. He has a keen interest in REST architecture, microservices, and cloud computing. He also blogs at geshan.com.np.