Learning objectives
After reading this article you will be able to:
- Understand what makes up the monthly cost of a Node.js app
- Measure how much memory your app uses so you pick the right plan
- Compare how free options, platforms and VPSs charge
Node.js is free, but the server it runs on is not. Search for "Node.js hosting cost" and you get everything: free instances, plans of a few dollars, cheap VPSs and platforms billed by the second. The numbers look impossible to compare because each one measures something different.
Splitting the cost into parts clears this up. Third-party prices change often, so this guide compares how each option charges. The numbers in this article are hypothetical, chosen to make the math easy. They are not any provider's prices; real values live on the official pricing pages, listed under sources.
What makes up the cost of hosting Node.js?#
A Node.js app is a process that keeps running and answers requests, events or messages. The monthly cost comes from five items:
- Compute: RAM and CPU reserved for the process. It is the main item and the one that varies most between providers.
- Uptime: a process that must be up 24 hours a day (API, bot, WebSocket) costs more than one that sleeps when there is no traffic.
- Database: almost every real app stores data. Running the database on the same machine has no extra fee but uses RAM; a separate database is another line on the bill.
- Domain and traffic: the domain is paid separately in every model, and some providers charge for traffic above the included allowance.
- Maintenance: the hours you spend updating the system, applying patches and fixing outages.
Node.js itself is not part of the bill: it is released under the MIT license, at no cost.
How much RAM does a Node.js app use?#
RAM decides the plan, so measure before you buy. The rss field of process.memoryUsage() is the total memory of the process, which is what counts against the limit of a container or a VPS. This Express 5 server exposes the number on a route:
// mem.mjs (npm install express)
import express from "express";
const app = express();
app.get("/", (req, res) => res.send("ok"));
app.get("/mem", (req, res) => {
const mb = (n) => Math.round(n / 1024 / 1024);
const m = process.memoryUsage();
res.json({ rssMB: mb(m.rss), heapUsedMB: mb(m.heapUsed), heapTotalMB: mb(m.heapTotal) });
});
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`listening on port ${port}`));In tests with a recent Node.js and Express 5, this server used 50 to 70 MB of RSS after a few hundred to 2,000 requests, with only 9 to 12 MB of heap in use. The rest is the runtime itself: the V8 engine, the loaded code and buffers.
A real app loads more: an ORM, a database client, validation, SDKs. Every dependency adds memory, and server-side rendering frameworks weigh more, so only measuring gives you the right number. Measure the peak under real traffic, add 30% headroom and round up to the next plan. The full method is in how much RAM and CPU your app needs.
CPU matters less for the bill. Node.js runs your JavaScript on one thread, so a single process only uses more than one core with workers or multiple processes.
How does each hosting option charge?#
| Option | Example | How it charges | What to watch |
|---|---|---|---|
| PC or laptop at home | your own hardware | power and internet | the app goes down when the machine does |
| Free instance | Render Free | no fee, with an hour allowance | sleeps after a period without traffic |
| Platform with shared hours | Heroku Eco | flat monthly fee for a pool of hours | sleeps without traffic |
| Always-on platform | Heroku Basic, Render paid plans | monthly fee per instance, by RAM and CPU | the price climbs with each RAM step |
| VPS | DigitalOcean Basic | per second, capped monthly | maintenance is on you |
A few details change how you read the table:
- Render: the entry workspace plan has no monthly fee, and you pay only for compute. Free instances share a monthly hour allowance per workspace, and a free web service spins down after a period without traffic.
- Heroku: Eco hours are shared by every Eco dyno on the account. The web dyno sleeps without traffic and uses no hours while asleep. Heroku stopped offering free dynos in November 2022.
- DigitalOcean: billing is per second, capped at the plan's monthly price, and each plan includes a transfer allowance.
If you plan to run the app on a machine at home, do the power math: a laptop that draws 30 W on average uses 30 × 24 × 30 = 21.6 kWh a month. Multiply by your electricity rate. At a hypothetical $0.15 per kWh, that is about $3.24. Add your internet plan, power cuts and the fact that the app goes down whenever the machine does.
Which costs are not on the price tag?#
- Sleeping has a price. A free service that shuts down after minutes without traffic takes seconds to come back on the first request. For a personal site that is fine; for a bot or a webhook it means lost messages or timeouts. The details are in the limits of free bot hosting.
- Currency and card fees. If the provider bills in a currency other than yours, the final amount moves with the exchange rate and your card's foreign transaction fees.
- Renewal. Some VPS providers sell a heavy discount for the first term and renew at full price. Read the renewal price before you pay, as how much a VPS costs shows.
- Database. A separate database is one more monthly fee, sometimes higher than the app itself. Compare the options in how much database hosting costs.
- Maintenance. On a VPS, system updates, firewall, reverse proxy, TLS and restarting the process when it dies are on you. If that takes 2 hours a month and your time is worth $20 an hour (hypothetical numbers), that is $40 a month of work.
How do you estimate your app's monthly cost?#
Build the estimate in four steps:
- Measure RAM with
process.memoryUsage()under real load and add 30%. - Pick the model by process type. If it must answer at any time, rule out options that sleep. If traffic is irregular and each run is short, compare serverless and containers.
- Add the extras: database, domain, backups and traffic above the allowance.
- Convert foreign prices to your currency and use the renewal price, not the promo one.
Hypothetical example: an API that peaks at 250 MB needs about 325 MB, so it fits in 512 MB. Assuming an always-on platform that charges $10 a month for 512 MB (a hypothetical value), that covers compute; an entry VPS usually has a lower fee, but you add maintenance. With a database and a domain, a small project usually lands somewhere between ten and a few tens of dollars a month. To choose between models beyond price, see the best way to host a Node.js app.
How do you spend less without losing stability?#
- Drop heavy dependencies you do not use. Every loaded library holds memory all the time.
- Do not keep everything in memory. Unbounded caches make RSS grow until it hits the plan limit. Cap the number of items or use an external cache.
- Run one process per app on small plans. Several processes with
clustermultiply RAM and only pay off when CPU is the bottleneck. - Tune the heap with
--max-old-space-size(in MiB) to stay below the plan's memory, so the process fails clearly instead of being killed by the system. - Build before you deploy. Compiling TypeScript or the front end on the production server needs more memory than running the result.
How to do this on Square Cloud#
On Square Cloud, most items on that bill fit into one monthly fee in Brazilian reais, paid by Pix or card, with 20% off on annual billing. Compute is the plan's RAM, a pool shared across your applications: Hobby costs R$12.49 a month with 1 GB and 1 vCPU, or R$24.99 with 2 GB and 2 vCPU. The example API, peaking at 250 MB, fits in the 512 MB minimum for a web application and still leaves room for a 256 MB bot on the 1 GB plan.
Staying on costs nothing extra: the container is always up, with no cold start or sleep mode. Traffic is unlimited, with no bandwidth or per-request charges (fair use policy), and every web app gets an HTTPS *.squareweb.app subdomain. Database hosting and custom domains start on Standard, from R$44.99 a month. On the maintenance side, automatic TLS, DDoS protection and a WAF come with every plan, and automatic restart, on by default for dashboard deploys, brings back a process that exits with an error.
There is no build step on the server: on start, the platform runs npm install when there is no node_modules, so build your front end first and upload the result. Your web app listens on 0.0.0.0, on the port in the PORT variable. Among several runtimes, such as Node.js, TypeScript (with no build step) and Python, see the ones available today on Runtimes and compare plans on pricing.
Deploy
Push from GitHub, the CLI or a ZIP and go live in seconds
FAQs
Can I host Node.js without paying anything?
Yes, with limits. Free instances, such as Render's, spin down after a period without traffic and have a monthly hour allowance. They suit tests and personal projects, not a bot or API that must answer at any time.
How much RAM does a Node.js API need?
A minimal Express server takes 50 to 70 MB of resident memory. A real API, with an ORM and dependencies, uses more. Measure it with process.memoryUsage() under load and add 30% headroom.
VPS or platform for Node.js: which is cheaper?
On the monthly price, an entry VPS is usually cheaper per GB of RAM. On the full bill, add the hours of server maintenance, which a VPS puts on you and a platform reduces.
Do I have to pay for Node.js itself?
No. Node.js is open source software released under the MIT license. You only pay for the machine or platform it runs on.
More in Deploy
See all 33 articles- What are environment variables?Environment variables are key-value pairs the operating system hands to a process at startup. Learn to read them in Node.js and Python and keep tokens out of code.
- What is a deployment?A deployment takes a version of your code to a server, prepares it and starts it. See the stages, the methods and how to roll back when it goes wrong.
- How much RAM and CPU does my app need?Size RAM and CPU by measuring your app's real peak and adding about 30% headroom. Learn how to measure in Node.js, Python and Java and what to do if short.
- Automatic deploys with GitHub ActionsAutomatic deploys with GitHub Actions ship your code to the server on every push. See the workflow step by step, secrets, tests before deploy and common errors.