
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.
Before you start
- A credit-based plan, or Enterprise with credits. Early Access is free; GA pricing will use credits for reserved memory and active CPU time, announced before GA.
- Netlify CLI 27.17.0 or later, and Node.js 24 or later for your build.
- Next.js, Astro and Nuxt don't run on Netlify Server yet.
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
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
- Netlify Server is now available in Early Access, Netlify changelog (10 Nov 2026)
- Netlify goes full stack: introducing Netlify Server, Netlify blog
- Get started, Real-time and Limits, Netlify Server docs
- netlify-cli on npm (27.17.0 published 10 Nov 2026)
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.