K6 Connectex issue

When I run my tests, I am getting such errors for some APIs. “connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.”

How to overcome this issue?

Hi @sumitkp

Welcome to the community forums :wave:

This error message typically indicates that the server the API is trying to connect to is not responding or is experiencing issues.

From what I understand, you don’t always get this error?

If that is the case, are you seeing any pattern in when you see the error? Is it only certain endpoints, or looks more associated to the load? Test with minimal load to make sure the script works, if you haven’t yet.

What do you see on the SUT (System Under Test)? Any logs or metrics indicating it can be overloaded?

  • Check the server’s resources: make sure the server has enough resources to handle the number of requests you are sending.
  • Check the endpoint’s availability: Sometimes, the endpoint may be temporarily down or unavailable. You can check the endpoint’s availability by visiting it in a browser or using a tool like curl while the test fails.

If there is a firewall or load balancer in between the load generator and the endpoints or your SUT, it’s also worth checking if there are any issues there (rate limitations, rejections, etc.).

Alternatively, if you are running a large test, it could also be a limitation on the load generation instance. Some pointers to fine tune that can be found in the k6 docs: Running large tests.

It can help if you provide more context: the (sanitized) script you are running, and more details on the errors (how many, when, etc.). Without more information about your specific setup and configuration, it may be difficult to pinpoint the exact cause.

I hope this helps.