Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

MariaDB warns that it could not raise max_open_files to the value it wants

Error[Warning] Could not increase number of max_open_files to more than 4096 (request: 4214)

Short answer

At start-up MariaDB works out how many file descriptors it wants, from max_connections and table_open_cache, then asks the system for them. The warning says the system capped the answer lower, for example at 4096. Raise LimitNOFILE in a systemd drop-in file, or lower the settings the request is based on.

  • Applies to MariaDB 10.11 and 11.4 LTS, Ubuntu 24.04 with its packaged systemd
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Compare what the server really got with what the service is allowed. The two numbers show where the cap sits.

    mariadb -e "SHOW VARIABLES LIKE 'open_files_limit'"
    systemctl show mariadb.service -p LimitNOFILE
  2. 2Match what you see, then jump to its fix

    1. 1LimitNOFILE in the unit is smaller than the request in the warningThe systemd service limit is lower than the server wantsFix
    2. 2The request value is only slightly above the cap, as in the example 4214 against 4096The request grows with max_connections and table_open_cacheFix
    3. 3The server is started by a script or container, not by systemdThe operating system hard limit is the ceilingFix

What does the error look like?

  • [Warning] Could not increase number of max_open_files to more than 4096 (request: 4214)
  • [Warning] Changed limits: max_open_files: 4096 max_connections: 151 (was 151) table_cache: 1990 (was 2000)

Cause 1 of 3

The systemd service limit is lower than the server wants

1Check

Under systemd the unit's LimitNOFILE is the number that counts, not the open_files_limit option alone.

systemctl show mariadb.service -p LimitNOFILE

2Fix

Add a drop-in file that sets a higher integer. Do not write infinity: on older systemd it means 65536, and on newer it means the kernel's fs.nr_open.

sudo systemctl edit mariadb.service
# in the editor add:
[Service]
LimitNOFILE=1048576

sudo systemctl daemon-reload
sudo systemctl restart mariadb

3Verify

open_files_limit is at least what the warning requested, and the warning is gone from the log.

mariadb -e "SHOW VARIABLES LIKE 'open_files_limit'"
sudo journalctl -u mariadb.service | grep -i max_open_files

Confirmed by mariadb.com

Did this fix it?

Cause 2 of 3

The request grows with max_connections and table_open_cache

1Check

When open_files_limit is 0, MariaDB calculates it from max_connections and table_open_cache. Large values of either raise the request.

mariadb -e "SHOW VARIABLES WHERE Variable_name IN ('max_connections','table_open_cache','open_files_limit')"

2Fix

If you do not need that many connections or cached tables, lower them. Otherwise raise the limit as in the previous cause.

# /etc/mysql/mariadb.conf.d/60-limits.cnf
[mysqld]
table_open_cache = 1500

3Verify

After a restart the warning no longer lists a request above the limit.

sudo journalctl -u mariadb.service | grep -i max_open_files

Confirmed by mariadb.com

Did this fix it?

Cause 3 of 3

The operating system hard limit is the ceiling

1Check

MariaDB cannot set open_files_limit above the hard limit imposed by the operating system, whatever the option file says.

ulimit -Hn
cat /proc/$(pidof mariadbd)/limits | grep -i 'open files'

2Fix

Raise the hard limit for the account or container that starts mariadbd, then restart the server. The limit set by the unit file replaces this for systemd installs.

# container example: docker run --ulimit nofile=65535:65535 mariadb:11.4

3Verify

The limits file shows the higher value for the running process.

cat /proc/$(pidof mariadbd)/limits | grep -i 'open files'

Confirmed by mariadb.com

Did this fix it?

How do I stop it coming back?

  • Set LimitNOFILE in a drop-in file, not in the packaged unit, so package updates do not undo it.
  • Recheck open_files_limit after changing max_connections or table_open_cache.
  • Keep table_open_cache sized to what you use; a cache larger than the working set only costs descriptors.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.