In Express.js, app.disable(name) turns a Boolean application setting off by setting it to false. It is the readable shorthand for app.set(name, false).
Common uses include hiding the X-Powered-By header with app.disable('x-powered-by'), or turning off trust proxy. Pair it with app.disabled() to check the flag, and app.enable() to turn it back on.
Syntax
Call app.disable in your Express.js app. Start with this line.
Express
app.disable(name)
Call
What it does
app.disable(name)
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.
Gate on environment. Only production runs the disable calls.
Turn two flags off.x-powered-by and etag become false.
Expose the state. The JSON route reports app.disabled(...) for each.
Dev stays default. Without NODE_ENV=production, those settings keep Express defaults.
Compatibility
Runtime Support
app.disable() is an Express.js application method. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not call it — they only see the resulting HTTP behavior.
✓ Server · Express 4 & 5
app.disable()
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers.
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
app.disable()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 a named Boolean application setting to false. It is the same as calling app.set(name, false) for that setting.
To stop Express from sending the X-Powered-By: Express response header, which is a common production hardening step.
Use app.disabled(name), which returns true when the setting is false. You can also read the raw value with app.get(name).
Yes. Call app.enable(name), which is the same as app.set(name, true).
No. It configures your Express server on Node.js. Browsers only receive the resulting HTTP behavior.