Skip to content

JMeter java.net.ConnectException

Fix JMeter java.net.ConnectException: wrong host or port, firewall, TLS mismatch, timeouts, and injector network path. Symptom, causes, and ordered fixes.

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

In View Results Tree, the JTL, or dashboard error tables you see messages such as:

  • java.net.ConnectException: Connection refused
  • java.net.ConnectException: Connection timed out
  • Non HTTP response code: java.net.ConnectException
  • Sample marked failed with no normal HTTP status (not 200/404/500)

Often every thread fails immediately, or failures start when the system under test (SUT) or network path is wrong.

CauseWhy it happens
Wrong host, port, or protocolHTTP Request Defaults / sampler still point at lab host or http vs https
Property not appliedPlan uses \${__P(host,)} but CLI omitted -Jhost=... (functions)
SUT not listeningProcess down, wrong interface, or container port not published
Firewall / security groupInjector cannot reach SUT (common in CI and Kubernetes)
Connect timeout too shortNetwork latency or cold start exceeds HTTP Request connect timeout
Distributed workers differWorkers lack DNS/route the controller has (distributed testing)
  1. Copy the exact error from the first failed sample (code + message).

  2. From the same machine that runs JMeter, test reachability (curl, Test-NetConnection, browser). If curl fails, it is not a JMeter sampler bug.

  3. Open HTTP Request Defaults and the failing sampler: protocol, server name, port, path. Prefer one defaults element so hosts stay consistent (web test plan).

  4. If the plan uses properties, print the effective command:

    Terminal window
    jmeter -n -t plan.jmx -Jhost=staging.example.com -Jport=443 -l out.jtl -j jmeter.log

    Confirm \${__P(host,localhost)} (or similar) is what you intend.

  5. Raise connect and response timeouts only after host/port are correct.

  6. On CI/K8s: check NetworkPolicy, egress, private DNS, and that the job runs in a network that can see the SUT (CI/CD).

  7. Distributed: reproduce on a worker shell; fix worker networking and data, not only the controller (remote testing).

ResourceUse when
Non HTTP response codeBroader non-HTTP failures
SSLHandshakeExceptionConnect works but TLS fails
GUI works, CLI failsHost only wrong under CLI
Docker / KubernetesContainer networking
Troubleshooting overviewFull triage tree

No. It usually means JMeter never completed a normal HTTP exchange. The failure is at the TCP/connect layer (or is wrapped as a non-HTTP sample error).

Why does it work on my laptop but fail in CI?

Section titled “Why does it work on my laptop but fail in CI?”

CI runners often cannot reach private staging hosts, or -Jhost / secrets differ. Test connectivity from the runner image first.

Should I increase threads to fix Connection refused?

Section titled “Should I increase threads to fix Connection refused?”

No. Connection refused means nothing accepted the socket. Fix host, port, process, or firewall first.

On this page