Nginx - Random 502 bad gateway errors

RR600

Verified User
Joined
Dec 26, 2019
Messages
58
I made a web panel where the main site administrators can create system's accounts, I'm currently using omines/directadmin API, it's an abandoned project but it still works.
The problem appears once in a while and exclusively when the admins are using the feature above, then they get the error in the subject.
It seems to be totally random and very rare, I'd say it happens once every 50 tries.
This feature is pretty intensive and consumes more hardware resources than any other in the system, however the accounts are always created with the same content, and as I said, most of the time it doesn't cause any problem. Also I think the system has enough RAM to handle it.

So, I'm looking for tips that help debugging the issue, nginx install is almost default I think.
Not sure if an error like this one produces any useful log.
Anyway, thanks in advance for any suggestion.
 
If it's really random and this might be used by customers server give a try with checking dmesg and check if you're not running out of tcp_wait and listen sockets - somxaconn value.

I know that from your description it is not directly telling but defaults in kernels from 90 to kernel 5.2 is 128 sockets and few years ago I found this an issue and always setting 4096 (default from kernel 5.2 as 128 is really low).
 
If it's really random and this might be used by customers server give a try with checking dmesg and check if you're not running out of tcp_wait and listen sockets - somxaconn value.

I know that from your description it is not directly telling but defaults in kernels from 90 to kernel 5.2 is 128 sockets and few years ago I found this an issue and always setting 4096 (default from kernel 5.2 as 128 is really low).

Thank you very much for the input, I'll keep that in mind, however I'm almost sure I found what's causing this problem.
I totally forgot I have a cronjob that every 5 minutes checks for a flag and if it's present then it runs /build rewrite confs, this is needed to apply nginx custom routing on new created accounts.
Adding a sleep of a few seconds should avoid the web server being restarted while the accounts are being created.
 
Back
Top