Error Parsing HTTP Request Header: 3 Ways You Can Fix it
Using the wrong protocol can cause this problem
2 min. read
Published on
Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more
When developing and using Tomcat, you might often encounter Error parsing HTTP request header. This error will prevent your project from running, but it can be fixed.
How can I fix the Error parsing HTTP request header?
Before we start, make sure that your server is configured to handle HTTPS requests. Also, ensure that you’re accessing the server using the right protocol, so try HTTPS instead of HTTP and vice versa.
1. Remove the listener
- Open the server.xml file.
- Locate the following listener:
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on"/>
- Remove it and save the changes.
- You can also try changing maxHttpHeaderSize by using this code: maxHttpHeaderSize=”1048576″
2. Modify application.properties
- Open the application.properties file.
- Now add the following lines:
logging.level.org.springframework.web: trace
logging.level.org.apache: trace - Save changes.
You can also set the max header size by adding one of the following lines: server.max-http-header-size=64kb
server.maxHttpHeaderSize = 102400
This solution works if you’re using SpringBoot.
3. Modify the application.yml file
- Open the application.yml file.
- Locate the following lines and remove them:
spring:
main:
lazy-initialization: false
This solution also applies to SpringBoot.
This error message can prevent your application from working correctly, but in most cases, it can be fixed by switching from HTTP or HTTPS or vice versa.
In web development, HTTP errors are fairly common, and we covered HTTP error 431 and HTTP error 413 in previous guides.
Before you go, we also have a guide on HTTP error 302 that might interest you. Did you manage to fix the Error parsing HTTP request header message? Share with us the solution that worked for you.