ARTIFACTORY: How to Resolve the Too many open files Nginx Error

JFrog Support
2023-01-22 11:11

If you’re running Nginx as afrontendto Artifactory, you may bump into your OS's/Nginx's defaultopen file descriptors limit. When this happens, Nginx'serror.logmight show something like this:

2010/04/16 13:24:16 [crit] 21974#0: *3188937 open() “/usr/local/nginx/..” failed (24: Too many open files), client: … server: foo.com, request: “GET /artifactory/.. HTTP/1.1”, upstream: “http://localhost:8081/artifactory..”, host: “foo.com”

You can generate alistof thedefault limitsfor givenLinuxmachine processes by running:cat /proc/$PID/limits

cat /proc/$PID/limits

Note: UsingNginx bufferingmay cause some issues with Artifactory. Therefore, you might consider turning offproxy_requestbuffering. More information is availableHERE.

By default, Nginx usesproxy_buffering. This means that when a client makes a request, Nginx buffers the upstream response payload to disk. Normally, Nginx saves those files to a temporary path and cleans up after itself when the request is completed. However, errors such as the one mentioned above can cause Nginx to stop cleaning up those temporary files. As a result, yourdisk space can fill upvery fast, with clean-ups occurring only when youshut downthe Nginx process.

A command such as:

lsof -a +L1 /var

might show some file descriptors with the term(deleted)next to them. Their existence is technically normal. However, if you see a "deleted" entry that isn't being cleaned up after a while, something could be wrong. And it’s a problem that can prevent your OS from being able to free up the disk space that’s being consumed by the un-cleaned up file handle.

If you’re usingsystemd, follow the stepsHEREto increase your Nginx max open files setting.

Published: Oct. 3, 2017

Last updated: Jan. 6, 2021

Keywords: Nginx, proxy request buffering, proxy buffering