res.end()ends the response process. It comes from Node core — http.ServerResponse.prototype.end — and Express exposes it on res. After you call it, do not write more body or call res.send() / res.json().
Use it to finish quickly with no body (or after you already set status/headers). Official guidance: if you need to respond with data, prefer res.send() or res.json() instead.
Syntax
Call res.end in your Express.js app. Start with this line.
GET /health (DB_READY unset)
→ 503
→ Body: Service unavailable
→ (json path never runs)
GET /health (DB_READY=1)
→ 200 { "ok": true }
How It Works
Branch on a condition. Unready DB → finish with 503 and end.
return after end. Stops the handler from reaching res.json.
Happy path uses json. Only one finish method runs per request.
Avoids ERR_HTTP_HEADERS_SENT. The classic bug is ending, then sending again.
Compatibility
Runtime Support
res.end() is the Node.js http.ServerResponse method, available on Express res. It runs on the server (Express 5 needs Node.js 18+). Browsers only receive the finished HTTP response.
✓ Server · Node core + Express
res.end()
Works wherever Express runs on a Node-compatible HTTP stack. Bun and Deno can run many Express apps with compatibility layers. Not a browser API.
ServerNode.js runtime API
Node.js18+ for Express 5 · core http.ServerResponse
Supported
BunExpress-compatible server apps
Supported
DenoVia npm compatibility / adapters
Supported
res.end()Node http.ServerResponse
Bottom line: Study and run these examples with Node.js and the express package. Prefer send/json for everyday response bodies.
Frequently Asked Questions
It ends the response process. It comes from Node’s http.ServerResponse. After end, you must not write more body or call send/json again.
Use end for empty or status-only replies (for example 204 No Content, or res.status(404).end()). For normal bodies, prefer res.send() or res.json().
Yes — you can pass a string or Buffer. Express docs still recommend send/json for typical data responses because they set Content-Type and related helpers for you.
It sets the status code, then ends with an empty body. Useful for simple error or no-content responses.
No. It is a stable Node/Express response method used widely for finishing responses.