How to fix the error Too Many Connections

schedule
2025-06-19 | 12:33h
update
2025-11-30 | 00:02h
person
Damian Ventura
domain
new.tutorialphp.net
How to fix the error Too Many Connections

When you have a web application (site, blog, forum, etc.) that has high demand, meaning a large number of users visit it, this translates into increased server consumption. If the web app uses a MySQL – MariaDB database and the queries are extremely high (due to poor web programming or a large number of users using the site), there’s a chance that MySQL – MariaDB will display this error:

1
2
3
.....
mysqli_connect(): (HY000/1040): Too many connections
.....

What does the error MySQL – MariaDB: Too Many Connections mean?

Advertisement

It means that too many requests are coming into MySQL – MariaDB, more than it can accept, more than it can queue or wait for.

How to fix it?

Simple, we need to increase the maximum limit for requests (connections) that MySQL – MariaDB support. To fix this problem:

Edit config file for MySQL – MariaDB.

If have a distro from RHEL (RedHat, Fedora, Centos, CentOS Stream, AlmaLinux, Rocky, etc):

1
/etc/my.conf.d/server.cnf

If have a distro from Debian (Kubuntu, Ubuntu, etc):

1
/etc/mysql/my.cnf

EDIT:

1
2
max_connections = 500
max_user_connections = 10

This will increase the maximum number of total connections from 100 (which is the default) to 500 and to a maximum of 10 connections per user (meaning database users, not visitors).

We save and exit, then restart the MySQL – MariaDB service, and that’s it. This change is permanent.

Advertisement

Imprint
Responsible for the content:
new.tutorialphp.net
Privacy & Terms of Use:
new.tutorialphp.net
Mobile website via:
WordPress AMP Plugin
Last AMPHTML update:
01.12.2025 - 14:49:52
Privacy-Data & cookie usage: