DeprecationWarning: Buffer() is deprecated due to security and usability issues (DEP0005)

Code (yours or a dependency) uses the deprecated new Buffer() constructor.

Exact message you may see Buffer() is deprecated
Seen on: Node.js

Meaning

new Buffer(n) could expose uninitialised memory. Use Buffer.from, Buffer.alloc or Buffer.allocUnsafe.

Common causes

  • Old dependency using new Buffer()
  • Legacy code in your project

⚡ Quick fix

  1. Replace with Buffer.from(string|array) or Buffer.alloc(size)
  2. Upgrade the dependency
  3. Find the source with --trace-deprecation

Detailed fix by platform

Node.js

  1. node --trace-deprecation app.js

How to diagnose

  1. Source — Your code or which package?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

componentWillMount renamed — Warning: componentWillMount has been renamed, and is not recommended for use. (React)componentWillMount re…config global deprecated — npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. (npm)config global depreca…defaultProps deprecated — Warning: Support for defaultProps will be removed from function components in a future major release. (React)defaultProps deprecat…DEP0040 — DeprecationWarning: The `punycode` module is deprecated (DEP0040) (Node.js)DEP0040Deprecated null to internal — Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated (PHP)Deprecated null to in…Dynamic property deprecated — Deprecated: Creation of dynamic property Foo::$bar is deprecated (PHP)Dynamic property depr…EBADENGINE — npm WARN EBADENGINE Unsupported engine / The engine "node" is incompatible with this module (Node.js)EBADENGINEERR_HTTP_HEADERS_SENT — Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client (Node.js)ERR_HTTP_HEADERS_SENTDEP0005

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.