Random 502 in POST request

Hello team,

I have some services and kong is reporting 502 errors in POST request, it is a random issue, the services are working normally and randomly appears a 502…

Do you know why is that?

Kong version 2.1.3

regards

Hi,

502 is usually the result of a bad response from an upstream server. Do you know which Kong service it is associated with?

You can try to add the header “Kong-Debug: 1” to see which route/service it is hitting and you can then try to hit that upstream service directly to see if it can be reproduced.

Other than that, you can look to the Kong logs for any additional detail. If this is a test environment you may get some more detail out of the log_level setting to debug. Any other errors you see may help if you can post them.

Hello Joedas,

Thank you so much for your response.

Regarding your questions,

Yes, I know the service associated to kong, and it’s quite strange, so for instance, it receives 1.5k request responding with a 200 and randomly during these 1.5k give 20 502…
What I don’t know if the issue can come from the service itself or in some part of the communication between Kong and the services it’s broken…

I set the header, and yes, the info provided is ok, but as said, it’s quite random and trying to force the error with no success…

Also in the logs, I found that message:
Connection reset by peer

Do you know if that error if from the service or in kong?

FYI: Currently Kong is running on kubernetes.

Cheers

more info:

We have more than one upstream in the end, we are using services and routes (kong 2.1.3) and this is happening in almost all of them.

we have a a front ahead of the services and there we cannot see the 502 error, we detected in the kong side.

Looks like we have the same issue:

Did not found solution for it. Disabling keepalive feature on Kong did not help.

Hello,

We have been sniffing traffic in the kong pods and we cannot see any 502, we only can see error 500 and we have detect some 502 checking the time and comparing it in the data captured…
Do you have any idea why I cannot see any 502?

Also, we have reduced the values to the next ones:
keepalive_pool_size: 128
keepalive_max_requests: 128
keepalive_timeout: 5

Regards