What is the max HTTP header size in NodeJS server?

By Gulshan Saini
Published in NodeJS
August 17, 2020
1 min read

The default max value of HTTP header size of NodeJS server is

  • 8192 (8KB) for Node version less than 14
  • 16384 (16KB) for Node version greater than 14

Let’s explore how we can inspect and change the max http header size.

Check default HTTP header size

To check the default HTTP header size we can log the value of property maxHeaderSize after creating an instance of http module as follows

Change HTTP header size

We can change the default HTTP header size value via command line while starting the server.

To change the value of http header size from command line, we need to pass argument --max-http-header-size=size while starting the server.

Or, if you are using nodemon, you could update the start up script as follows

Let’s create a simple NodeJS server with following code and save it in file server.js

Next, open a terminal and navigate to the directory where code for our server is saved.

In the terminal type node --max-http-header-size=1024 server.js.

If you now open URL in browser, you should see updated value of HTTP headers size.

setting http header size via command line
setting http header size via command line


Previous Article
How to create a server in NodeJS?

Gulshan Saini

Fullstack Developer

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Related Posts

How to create a server in NodeJS?

August 16, 2020
1 min
© 2020, All Rights Reserved.

Quick Links

Advertise with usContact Us

Social Media