Close-up of a server rack glowing green in the dark, like the long-running Node.js instances Netlify Server keeps alive for your backend
Photo by Tyler on Unsplash · source · credits

Netlify Server Tutorial: Run an Express App With WebSockets on Netlify

Also available in Hindi: यह लेख हिंदी में पढ़ें

Netlify launched Netlify Server in Early Access on 10 November 2026. It runs your backend as a long-lived Node.js process that Netlify provisions, scales and stops when idle, so an existing Express, Hono, Fastify or Koa app can run without adapters and keep WebSocket connections open. Below: a minimal WebSocket server, the limits that matter, and when to stay on Functions.

Server or Functions?

A function handles one request per instance and finishes when it responds. That suits webhooks, scheduled jobs and small endpoints, but it can't hold a WebSocket open. A server handles many requests at once in one process, keeps database pools and caches warm, and holds WebSocket and Server-Sent Events connections. Netlify says Functions are not being replaced.

Comparison of Netlify Functions and Netlify Server: one request per instance versus a long-lived process with WebSockets
From Netlify's changelog, launch blog and docs. Illustration, not a screenshot.

Before you start

Step 1: create the entry file

Netlify looks for netlify/server/index.ts (or .mts, .js, .mjs), and a project can have one server. Install the packages:

npm install express ws @netlify/server

Step 2: add WebSockets

// netlify/server/index.mjs
import express from "express";
import { WebSocketServer } from "ws";

const app = express();
app.get("/api/hello", (req, res) => res.json({ ok: true }));

const server = app.listen(process.env.PORT);
const wss = new WebSocketServer({ server });
wss.on("connection", (ws) => {
  ws.on("message", (data) => ws.send(data));
});

Start the app with listen() on process.env.PORT. If you export the Express app directly instead, Netlify answers WebSocket upgrade requests with a 501.

Step 3: run and deploy

Run netlify dev: the CLI starts your server next to your frontend and functions and restarts it when files under netlify/server/ change. Deploy as usual with a Git push or netlify deploy. Every deploy, including Deploy Previews, gets its own server.

Limits to design around

Netlify Server Early Access limits: instances, idle shutdown, request duration, header timeout and lifetime
From Netlify Server docs. Illustration, not a screenshot.

Connections close at the request duration limit and when an instance is replaced, so make browser clients reconnect. Each instance holds its own sockets, so keep shared state such as chat messages in Netlify Database or Netlify Blobs, not only in memory.

Wait if you need always-warm instances (a minimum instance count comes after Early Access) or a full-stack framework.

Compare hosts in free hosting for side projects, AI agent hosting options and how to deploy a vibe-coded app, or read our Netlify review.

Sources

FAQ

Is Netlify Server free?

Yes during Early Access. Requests still count toward your web requests meter.

Can I use Socket.IO?

Yes. Netlify's docs say you can attach ws or Socket.IO to your server.

How many WebSockets fit on one instance?

About a couple of hundred, counted separately from normal request concurrency.

Does it replace Netlify Functions?

No. Functions remain the choice for webhooks, scheduled jobs and other discrete work.

About the author

Suraj Kumar builds and edits AIUseFlow, a directory of AI tools for vibe coders, agent builders and creators. Guides like this one walk through a practical workflow with cited sources — not a news wire rewrite. How we rank tools.

Get the weekly stack

Rank movers and new AI tools for builders, once a week. Free, no spam, unsubscribe anytime.