How to fix Error: HTTP/2 invalid settings frame (malformed settings) in Node.js

Node.jsINTERMEDIATEMEDIUMUpdated Dec 9, 2025· 117 views

This error occurs when Node.js HTTP/2 session receives a SETTINGS frame that does not comply with HTTP/2 protocol specifications. The settings frame may contain invalid parameter IDs, out-of-range values, or malformed data that the HTTP/2 parser cannot process.

Quick fix

Fixes ERR_HTTP2_INVALID_SETTINGS_FRAME

# On Linux/macOS
NODE_DEBUG=http2 node your-app.js

# On Windows (PowerShell)
$env:NODE_DEBUG='http2'
node your-app.js
  1. Enable HTTP/2 debugging to inspect the settings frame
  2. Verify the remote server is compliant
  3. Check if the server is behind a proxy or CDN
  4. Update Node.js to the latest version
node.js — error
# On Linux/macOS
NODE_DEBUG=http2 node your-app.js
# On Windows (PowerShell)
$env:NODE_DEBUG='http2'
node your-app.js
Error: HTTP/2 invalid settings frame (malformed settings)

What this error means

The "HTTP/2 invalid settings frame (malformed settings)" error occurs when Node.js attempts to process HTTP/2 SETTINGS frames that violate the HTTP/2 specification (RFC 7540). A SETTINGS frame is used by HTTP/2 to exchange connection parameters between client and server. This error can arise from several protocol violations: - Settings parameters with unknown IDs - Parameter values outside valid ranges (e.g., max frame size < 16KB or > 24MB) - Incomplete or truncated SETTINGS frames - Incorrect frame length or structure - Server sending settings with deprecated or unsupported parameter combinations The error indicates that either the remote peer is sending malformed HTTP/2 data, or there's an issue with how the connection is being negotiated.

Typical symptoms

  • HTTP/2 connection immediately closes with settings frame error
  • Error message: "Error: HTTP/2 invalid settings frame (malformed settings)"
  • Connection fails during HTTP/2 handshake
  • GOAWAY frame received from server with protocol error
  • Issue occurs with specific HTTP/2 servers or proxies
  • Error in streams created after connection initialization
  • Intermittent failures that depend on connection state
  • Client connecting from Node.js while other clients work fine

Common causes

  1. Server sends SETTINGS frame with invalid parameter ID (outside 0x0000-0x0006 range)
  2. Settings parameter value exceeds maximum allowed (e.g., max frame size > 2^24-1 bytes)
  3. Settings parameter value below minimum required (e.g., max frame size < 16KB)
  4. HTTP/2 proxy or intermediary corrupts or incorrectly transforms SETTINGS frames
  5. Server implementation bug in HTTP/2 stack sends malformed settings
  6. TLS middlebox or network device interferes with HTTP/2 frames
  7. Connection receives SETTINGS frame with incorrect octet length (not multiple of 6 bytes)
  8. Initial connection window size set to value larger than max flow window size

How to fix "Error: HTTP/2 invalid settings frame (malformed settings)"

1Enable HTTP/2 debugging to inspect the settings frame

Enable Node.js HTTP/2 debugging to see detailed frame information:

bash
# On Linux/macOS
NODE_DEBUG=http2 node your-app.js

# On Windows (PowerShell)
$env:NODE_DEBUG='http2'
node your-app.js

This will output detailed logs showing the exact SETTINGS frame content and which parameter is invalid.

2Verify the remote server is compliant

Test the HTTP/2 server with standard tools:

bash
# Using curl to test HTTP/2 server
curl -I --http2 https://example.com/

# Using h2spec to validate HTTP/2 compliance
go install github.com/summerwind/h2spec/v2@latest
h2spec -port 443 -tls example.com

If the server fails h2spec tests, it has HTTP/2 compliance issues that need to be fixed on the server side.

3Check if the server is behind a proxy or CDN

HTTP/2 proxies or CDNs may incorrectly transform settings frames. Test direct connection:

bash
# Try connecting directly to the origin IP (if accessible)
dig +short example.com  # Get the IP
curl -I --http2 --connect-to example.com:443:x.x.x.x:443 https://example.com/

# Or bypass proxies by connecting to the host directly
telnet example.com 443

If direct connection works but proxied connection fails, the intermediary is corrupting HTTP/2 frames.

4Update Node.js to the latest version

Ensure you have the latest Node.js version with HTTP/2 patches:

bash
# Check current version
node --version

# Update to the latest stable version (using nvm)
nvm install --latest-npm node
nvm use node

# Or update manually from https://nodejs.org/

HTTP/2 protocol support improves with each Node.js release. Older versions may have stricter or less correct validation.

5Create an HTTP/2 session with explicit settings

Configure your HTTP/2 client with conservative settings:

javascript
const http2 = require('http2');

// Create HTTP/2 session with explicit settings
const session = http2.connect('https://example.com/', {
  settings: {
    headerTableSize: 4096,
    enablePush: false,
    initialWindowSize: 65535,
    maxFrameSize: 16384,  // Use minimum allowed value
    maxConcurrentStreams: 100,
    maxHeaderListSize: 8192
  }
});

session.on('error', (err) => {
  console.error('Session error:', err.message);
});

session.on('remoteSettings', (settings) => {
  console.log('Received settings from server:', settings);
});

Start with conservative values and the error persists, the issue is on the server side.

6Implement error handling and fallback

Add proper error handling for HTTP/2 failures:

javascript
const http2 = require('http2');

async function makeRequest() {
  return new Promise((resolve, reject) => {
    const session = http2.connect('https://example.com/');

    session.once('error', (err) => {
      console.error('HTTP/2 error:', err.message);

      // If it's a settings frame error, log details
      if (err.message.includes('settings frame')) {
        console.error('Server sent invalid HTTP/2 settings');
        console.error('Consider contacting the API provider');
      }

      reject(err);
    });

    const req = session.request({ ':path': '/api/data' });

    req.on('response', (headers) => {
      resolve(headers);
      session.close();
    });

    req.end();
  });
}

makeRequest().catch(err => {
  console.error('Request failed:', err.message);
});
7Contact the server provider with debug information

If the issue persists and the remote server cannot be changed, contact the API provider:

1. Provide the exact error message and Node.js version
2. Include the NODE_DEBUG=http2 output showing the invalid settings
3. Share the results from h2spec testing
4. Request they review their HTTP/2 implementation

Example message:

bash
I'm getting "HTTP/2 invalid settings frame (malformed settings)" when connecting
from Node.js v{version}. The connection fails immediately during the settings
negotiation phase. Testing with h2spec shows [list issues found]. Can you review
your HTTP/2 settings frame implementation against RFC 7540?

Advanced notes

HTTP/2 SETTINGS Frame Structure:

Each SETTINGS frame contains zero or more settings, each as a parameter ID (2 bytes) + value (4 bytes). Valid parameter IDs per RFC 7540:
- 0x0001: HEADER_TABLE_SIZE (0 to 2^32-1)
- 0x0002: ENABLE_PUSH (0 or 1 only)
- 0x0003: MAX_CONCURRENT_STREAMS (0 to 2^32-1)
- 0x0004: INITIAL_WINDOW_SIZE (0 to 2^31-1)
- 0x0005: MAX_FRAME_SIZE (16384 to 2^24-1)
- 0x0006: MAX_HEADER_LIST_SIZE (0 to 2^32-1)

Any other parameter ID or out-of-range value triggers this error.

Common Server-Side Issues:

1. Reverse proxy misconfiguration: nginx/Apache HTTP/2 settings may be incorrectly passed to upstream
2. Node.js version mismatch: Some HTTP/2 servers have bugs with specific Node.js versions
3. TLS/ALPN negotiation issues: Server may offer HTTP/2 but implementation is incomplete
4. Memory constraints: Some servers corrupt SETTINGS when under load

Debugging Steps:

Use Wireshark to capture the actual HTTP/2 frames:

bash
# Capture HTTP/2 traffic
tcpdump -i eth0 -w http2.pcap 'tcp port 443'

# Or use mitmproxy to intercept and inspect HTTP/2
mitmproxy --mode reverse:https://example.com --http2 -p 8443

Frame inspection will show the exact bytes causing the error.

When to Blame the Server:

This error is almost always a server-side bug. The Node.js HTTP/2 implementation is mature and RFC-compliant. If h2spec fails or you see this error consistently, the remote server needs fixing. Don't just increase timeouts or disable validation—that masks a real protocol violation.

Frequently asked questions

What does "ERR_HTTP2_INVALID_SETTINGS_FRAME" mean?
js attempts to process HTTP/2 SETTINGS frames that violate the HTTP/2 specification (RFC 7540). A SETTINGS frame is used by HTTP/2 to exchange connection parameters between client and server. , max frame size < 16KB or > 24MB) - Incomplete or truncated SETTINGS frames - Incorrect frame length or structure - Server sending settings with deprecated or unsupported parameter combinations The error indicates that either the remote peer is sending malformed HTTP/2 data, or there's an issue with how the connection is being negotiated.
How do I fix "ERR_HTTP2_INVALID_SETTINGS_FRAME"?
This error occurs when Node.js HTTP/2 session receives a SETTINGS frame that does not comply with HTTP/2 protocol specifications. The settings frame may contain invalid parameter IDs, out-of-range values, or malformed data that the HTTP/2 parser cannot process.
What causes "ERR_HTTP2_INVALID_SETTINGS_FRAME"?
Server sends SETTINGS frame with invalid parameter ID (outside 0x0000-0x0006 range) Settings parameter value exceeds maximum allowed (e.g., max frame size > 2^24-1 bytes) Settings parameter value below minimum required (e.g., max frame size < 16KB)
Is the "ERR_HTTP2_INVALID_SETTINGS_FRAME" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading