I'm running a Java based system on CentOs and I sometimes see that clients of a service experience "Connection refused" errors for short periods. The interesting is that the server is, at the same time, serving requests. The error is intermittent.

Is it possible that the listener socket's backlog fills up for a short time and it causes new requests to be refused? I'm running out of clues and I wasn't able to reproduce this outside the continuous integration system so far.


I think your guess is correct, man listen(2) says (emphasis is mine):

The backlog argument defines the maximum length to which the queue of pending connections for sockfd may grow. If a connection request arrives when the queue is full, the client may receive an error with an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may be ignored so that a later reattempt at connection succeeds.

  • Yes, this is what I found, as well. But I wasn't able to artificially reproduce it. Do you have any idea how this could be done? I tried this: gist.github.com/andrask/d2d14cc0d2b6ee3d3076 But it never gets refuse or timeout or anything. It always succeeds. – allprog Dec 9 '15 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.