Skip to content

JMeter org.apache.http.NoHttpResponseException

Fix JMeter org.apache.http.NoHttpResponseException: The target server failed to respond. Understand HTTP keep-alive race conditions and connection reuse tuning.

Difficulty
intermediate
Guide type
troubleshooting
Estimated read time
6 min read
Last verified version
Verified JMeter 5.6

org.apache.http.NoHttpResponseException in JMeter

Section titled “org.apache.http.NoHttpResponseException in JMeter”

In View Results Tree, JTL results, or jmeter.log, HTTP samplers fail intermittently with:

Response code: Non HTTP response code: org.apache.http.NoHttpResponseException
Response message: Non HTTP response message: The target server failed to respond

The error typically appears intermittently during tests with think time, between loop iterations, or when reusing pooled connections over HTTP Keep-Alive.

NoHttpResponseException occurs when JMeter sends an HTTP request over an established persistent (Keep-Alive) TCP socket that the server or intermediate proxy has already closed due to an idle timeout. When JMeter transmits bytes on the stale connection, the server drops or resets the socket without returning an HTTP response line.

CauseWhy it happens
Keep-Alive race conditionServer idle timeout (e.g. 5s) is shorter than JMeter’s connection reuse interval / think time
Server connection backlog fullTarget server or load balancer terminates idle client connections under heavy memory or socket pressure
Intermediate proxy / NAT timeoutFirewalls (AWS ALB, Nginx, Cloudflare) close idle TCP connections silently without TCP FIN packets
Stale connection checking disabledJMeter uses pooled sockets without validating whether the connection is still alive before sending data
Thread iteration statePrevious thread loop left an open TCP connection in a state that the server subsequently closed

1. Validate Idle Connections Before Reuse in user.properties

Section titled “1. Validate Idle Connections Before Reuse in user.properties”

Configure JMeter’s underlying Apache HttpComponents HttpClient to check whether a connection is stale before transmitting a new request. Add the following to bin/user.properties:

# Validate idle persistent connections if inactive for more than 2000ms
httpclient4.validate_after_inactivity=2000
# Set maximum connection Time-To-Live (in milliseconds)
httpclient4.time_to_live=60000
# Set idle connection timeout (in milliseconds)
httpclient4.idletimeout=10000

2. Reset HTTP State on Thread Group Iteration

Section titled “2. Reset HTTP State on Thread Group Iteration”

Ensure each iteration starts with a clean connection state if your virtual users simulate independent sessions:

  1. Open your Thread Group.
  2. Check Same user on each iteration if simulating sticky browser sessions, or uncheck it if each iteration represents a distinct new user.
  3. In HTTP Request Defaults, ensure the implementation is set to HttpClient4 (the default and recommended client).

3. Match JMeter Keep-Alive Timeout with Server Keep-Alive

Section titled “3. Match JMeter Keep-Alive Timeout with Server Keep-Alive”

Check your web server / reverse proxy Keep-Alive configuration:

  • Nginx: keepalive_timeout 65; (ensure JMeter httpclient4.idletimeout is lower than this value, e.g. 60000).
  • Apache HTTPD: KeepAliveTimeout 5.
  • AWS ALB: Default idle timeout is 60 seconds.

If JMeter holds connections longer than the upstream timeout, JMeter will attempt to send requests over dead sockets.

4. Enable Automatic Connection Retry Strategy

Section titled “4. Enable Automatic Connection Retry Strategy”

By default, JMeter’s HttpClient4 does not automatically retry non-idempotent requests (like POST or PUT) if a socket drops. You can configure retry behavior in user.properties:

# Number of retries on connection reset (default: 0 in modern JMeter)
httpclient4.retrycount=1
# Whether to retry request sent failure
httpclient4.request_sent_retry_enabled=true
ResourceUse when
Socket closed / connection resetServer abruptly resets active TCP connection
SocketTimeoutExceptionServer receives request but response is too slow
HTTP 502/503/504Proxy responses when backends fail to respond
Properties Cheat SheetQuick lookup for httpclient4.* properties

Why does NoHttpResponseException happen mostly during think times?

Section titled “Why does NoHttpResponseException happen mostly during think times?”

When threads pause for Timers (e.g. 10 seconds), the pooled TCP connection sits idle. If the server idle timeout is 5 seconds, the server closes the connection during the think time. When JMeter resumes, it tries to use the dead connection.

Is NoHttpResponseException a bug in JMeter?

Section titled “Is NoHttpResponseException a bug in JMeter?”

No. It is a standard TCP/HTTP Keep-Alive timing condition. Setting httpclient4.validate_after_inactivity=2000 prevents JMeter from writing to closed sockets.

Should I disable Keep-Alive in HTTP Request Defaults?

Section titled “Should I disable Keep-Alive in HTTP Request Defaults?”

Only if your target application architecture does not support Keep-Alive. Disabling Keep-Alive forces a fresh TCP and TLS handshake for every single request, which creates CPU overhead and can cause ephemeral port exhaustion.

On this page