Fix nginx "open_file_cache" must have the "max" parameter
Fix the nginx open_file_cache error by adding max=N to enable the cache or using off to disable it. Verify the change with nginx -t.
2026/11/21 23:15:48 [emerg] 1#1: "open_file_cache" must have the "max" parameter in /test/nginx.conf:4nginx: [emerg] "open_file_cache" must have the "max" parameter in /test/nginx.conf:4nginx: configuration file /test/nginx.conf test failed"open_file_cache" must have the "max" parameter means the line enabling the cache is missing its entry limit. The test fails when the line specifies only inactive=30s, as on line 4 above. Add max=N on that line to enable the cache in that context. nginx 1.28.0 HTTP configuration parser
[1] Find the directive using the path and line number after in. If the diagnostic points to an included file, open that file and check whether the directive is in an http, server, or location block. Save a copy of the file before editing.
The first output came from this test file mounted at /test/nginx.conf in the official image. The command returned exit code 1.
events {} http { open_file_cache inactive=30s;}$ nginx -t -c /test/nginx.conf[2] Add a positive integer max to the same directive to enable caching. Keep the existing inactive=30s value. The test changed only this line and used the same configuration path.
events {} http { open_file_cache max=1000 inactive=30s;}$ nginx -t -c /test/nginx.confnginx: the configuration file /test/nginx.conf syntax is oknginx: configuration file /test/nginx.conf test is successfulmax=1000 is an example limit. When the cache overflows, nginx evicts the least recently used entries. inactive=30s sets how long an unused entry can stay in the cache. The default is 60 seconds. The cache can retain open file descriptors and file metadata. Check the worker's open-file limit when changing the cache size. nginx open_file_cache reference · Check nginx worker open-file limits
[3] Disable the cache by replacing the line with open_file_cache off;. Use an explicit off to disable caching in this context if the parent has it enabled. A child block with no setting of its own inherits the parent's setting. The same test configuration also passed nginx -t with the following line in its http block.
events {} http { open_file_cache off;}[4] Test the production configuration before reloading. These commands assume nginx uses its default arguments. If the service sets -c, -p, or -g, use the same arguments in the test and follow the service's reload procedure.
$ sudo nginx -tIf the test fails, hold the reload and check the file and line number in the new error. If the test passes, reload with the following command. To roll back, restore the last working configuration to the same path, test it, and reload again. nginx command-line options
$ sudo nginx -s reloadAnalyze your Nginx log in the browser ↗ — nothing is uploaded.