Back

October 2026

How to deploy a Node.js API on Render

In this tutorial, we are going to deploy a small Node.js API to Render. We'll write a couple of JSON endpoints, connect the GitHub repository, and test the deployed API over HTTPS.

I am using a Free web service for this example. It is enough to follow along, but it spins down when idle and has usage limits. Check Render's current Free plan limits before using it for a project that needs to stay available.

Create the API

You will need Node.js 24, GitHub, and a Render account. Create a GitHub repository and clone it to your computer. We will use Node's built-in HTTP module, so this example does not need Express or another dependency.

Create package.json:

{
  "name": "render-node-api",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "engines": {
    "node": "24.x"
  },
  "scripts": {
    "start": "node server.js"
  }
}

Create server.js:

import http from "node:http";

const port = Number(process.env.PORT || 10000);
const server = http.createServer((request, response) => {
  const path = new URL(request.url, "http://localhost").pathname;
  response.setHeader("Content-Type", "application/json");
  if (request.method !== "GET" && request.method !== "HEAD") {
    response.writeHead(405, { Allow: "GET, HEAD" });
    response.end(JSON.stringify({ error: "Method not allowed" }));
    return;
  }
  if (path === "/healthz") {
    response.end(JSON.stringify({ status: "ok" }));
    return;
  }
  if (path === "/") {
    response.end(JSON.stringify({ message: "Hello from Node.js" }));
    return;
  }
  response.writeHead(404);
  response.end(JSON.stringify({ error: "Not found" }));
});
server.listen(port, "0.0.0.0", () => {
  console.log(`Listening on 0.0.0.0:${port}`);
});

The root route returns JSON. /healthz gives Render a small endpoint to check. We read PORT from the environment and listen on 0.0.0.0.

Install the project and try it locally:

npm install
npm start

In another terminal, run:

curl http://localhost:10000/
curl http://localhost:10000/healthz

Commit server.js, package.json, and the generated package-lock.json, then push them to GitHub. Add node_modules/ and .env to .gitignore. The lockfile matters because our Render build command uses npm ci.

Create a web service

Open your Render dashboard, hit New, then Web Service.

Select New, then Web Service

Choose Git Provider and select your repository. If GitHub is not connected yet, follow Render's connection flow and give it access to the repository you want to deploy.

Give the service a name, such as node-api-tutorial. Set Language to Node, choose your branch, and pick a region. I am using Oregon.

Select the Node.js runtime and source branch

If you copied these files into the root of a new repository, leave Root Directory empty. My screenshot uses examples/render-node-api because the example lives inside a larger repository, on the codex/render-api-examples branch. Use the directory and branch that contain your own files.

Set the build and start commands

Use the following settings:

Setting Value
Language Node
Build Command npm ci
Start Command npm start
Compute Free for this example

Build command, start command, and Free compute

npm ci installs from the committed lockfile. npm start runs node server.js through the script in package.json. There is no compilation step in this small example.

Under Environment Variables, I set NODE_VERSION to 24.21.0 for this deploy. The package also limits the major version with "node": "24.x". You can use a different supported version that you have tested; see Render's Node version settings.

Open Advanced and set Health Check Path to /healthz.

Set the health check path to /healthz

Our example does not need an API key or database password. If your app does, add those values under Environment Variables, rather than putting them in the repository. Review the settings and hit Deploy web service.

Test the deployed API

Wait for the deploy to show Live, then open the onrender.com URL shown on the service page. Your URL will be different from mine.

Live Node.js web service and its public URL

The root route should return:

{"message":"Hello from Node.js"}

Add /healthz to that URL. You should get:

{"status":"ok"}

You can also use curl. Replace the placeholder URL with the one from your dashboard:

curl https://YOUR-SERVICE.onrender.com/
curl https://YOUR-SERVICE.onrender.com/healthz

I checked both routes on the deployed example. Render provides HTTPS for the public URL. Your app listens on HTTP inside the service, so you do not need to set up a certificate in this code.

If the deploy fails

If npm ci fails, check that package-lock.json was committed and agrees with package.json. If Render runs the wrong entry file, check the start script and Root Directory. Open the failed deploy to see the install and startup logs.

If Render cannot detect an open port, check that the app binds to 0.0.0.0 and uses PORT. Binding only to localhost can work on your computer and fail in a hosted service.

A Free service can take longer to answer after it has been idle. Its filesystem is temporary, so use a database or object storage for data you need to keep. The tutorial API does not store any data.

That's it! You have a Node.js API running on Render. When you push another change to the connected branch, Render can build and deploy it automatically. Before adding private application data, add the authentication your endpoints need; a web service's URL is public.