MariaDB warns that it could not raise max_open_files to the value it wants
[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.
Fix it fast
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 LimitNOFILE2Match what you see, then jump to its fix
- 1
LimitNOFILE in the unit is smaller than the request in the warningThe systemd service limit is lower than the server wantsFix - 2
The 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
The server is started by a script or container, not by systemdThe operating system hard limit is the ceilingFix
- 1
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 LimitNOFILE2Fix
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 mariadb3Verify
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_filesConfirmed by mariadb.com
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 = 15003Verify
After a restart the warning no longer lists a request above the limit.
sudo journalctl -u mariadb.service | grep -i max_open_filesConfirmed by mariadb.com
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.43Verify
The limits file shows the higher value for the running process.
cat /proc/$(pidof mariadbd)/limits | grep -i 'open files'Confirmed by mariadb.com
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
systemctl start mariadb hangs, then fails with a timeout
mariadb.service start-pre operation timed out. Terminating.
When mariadb.service fails or hangs, the journal and the server's own start-up messages say why.
3 causes, each with a fixDatabases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
An EC2 instance cannot reach its RDS database
Could not open connection to the host, on port <port>: Connect failed
RDS denies all access until a security group allows it.
3 causes, each with a fixDatabases
Locked out of a fresh MariaDB install as root on Mac or Linux
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
A fresh MariaDB root account is not a normal password account.
3 causes, each with a fixDatabases
An Aria table fails with 'Read page with wrong checksum' (error 1030, code 176)
ERROR 1030 (HY000): Got error 176 "Read page with wrong checksum" from storage engine Aria
Code 176 means MariaDB's Aria engine read a data or index page whose checksum does not match, so that table file is damaged.
3 causes, each with a fix