In Express.js, res.sendStatus(statusCode) sets the response status and sends the registered status message as a plain text body. Example: res.sendStatus(404) responds with status 404 and body Not Found.
Use it for short status-only replies (health checks, quick denies). For a custom message or JSON error, use res.status(code) with res.send() or res.json() instead.
Syntax
Call res.sendStatus in your Express.js app. Start with this line.
Express
res.sendStatus(statusCode)
Call
What it does
res.sendStatus(statusCode)
Primary signature.
Install with npm install express. Create the app with const app = express() before you use this API in an Express.js tutorial project.
GET /secret
→ 403 Forbidden
→ Body: { "error": "Admins only" }
(If sendStatus(403) were used)
→ Body: Forbidden
How It Works
Know the limit.sendStatus only accepts the code — not a custom string.
Set status first.res.status(403) prepares the status line.
Send your payload..json({…}) writes a structured error clients can parse.
Express 5 tip. Old res.send(403) is gone — use sendStatus or status().send.
Compatibility
Runtime Support
res.sendStatus() is an Express.js response method. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers only receive the HTTP status and body.
✓ Server · Express 4 & 5
res.sendStatus()
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers. Not available in the browser.
ServerNode.js runtime API
Node.js18+ for Express 5 · 14+ typical for Express 4
Supported
BunExpress-compatible server apps
Supported
DenoVia npm compatibility / adapters
Supported
res.sendStatus()Express on Node.js
Bottom line: Study and run these examples with Node.js and the express package. Copy a snippet into a local file and start the server with node.
Frequently Asked Questions
It sets the HTTP status code and sends the registered status message as a text body — for example 404 sends Not Found. Unknown codes send the number as the body.
res.sendStatus(code) always uses the standard reason phrase. res.status(code).send(body) lets you choose any custom body (string, JSON, and so on).
No. Express 5 removed res.send(statusNumber). Use res.sendStatus(404) instead, or quote a number if you truly mean to send digits as text.
No. sendStatus finishes the response. A second send causes headers-already-sent errors.
No. It runs on your Node.js server. Browsers only receive the status line and body over HTTP.