Post by mandom » Wed Jul 09, 2025 5:27 pm

Hi everyone,

I'm running OpenCart 3.0.4.0 on PHP 8.3 on shared hosting, and I'm encountering an issue with hitting the **max\_user\_connections** limit on my MySQL database. This error occurs around once a day, regardless of the time of day.

### Error Log:
```
[08-Jul-2025 17:00:02 UTC] PHP Fatal error: Uncaught Exception: Error: Could not connect to the database.<br>Error No: 1203<br>Message: User pattayak_newXXX already has more than 'max_user_connections' active connections in /home/pattayak/public_html/system/library/db/mysqli.php:13
Stack trace:
#0 /home/pattayak/storage3040/modification/system/library/db.php(36): DB\MySQLi->__construct()
#1 /home/pattayak/public_html/system/framework.php(83): DB->__construct()
#2 /home/pattayak/public_html/system/startup.php(104): require_once('/home/pattayak/...')
#3 /home/pattayak/public_html/index.php(19): start()
#4 {main}
thrown in /home/pattayak/public_html/system/library/db/mysqli.php on line 13
```

### Site and Hosting Details:

* **Traffic**: Around 100 visitors per day.
* **Installed Modules**: 20 modules.
* **Cron Jobs**: 5 cron jobs (non-overlapping, scheduled at different times).
* **Hosting**: Shared hosting with a 20 DB connection limit.

### Actions Taken:

1. Optimized cron jobs to ensure they don't overlap.
2. Considered changing session storage from database to file-based to reduce database load. I've read that this can potentially reduce connections by 50-60%. Is this true?
3. I'm currently running the site with fairly light traffic, so I'm not sure why it's hitting the DB connection limit.

### Question:

Is upgrading to a VPS the only solution, or is there another way to reduce the database connections without moving to a VPS? For example, will switching to file-based sessions make a significant difference?

I would appreciate any insights or suggestions on how to resolve this issue.

Thanks in advance for your help!

New member

Posts

Joined
Tue Jun 30, 2015 4:44 pm

Post by by mona » Wed Jul 09, 2025 5:58 pm

1. If you have category count on - turn it off in settings and see if that helps.
2. Maybe a link to your site - Themes and extensions could be an issue.
3. Have you looked into different hosting?
4. Try a session debloater like this one for example https://www.opencart.com/index.php?rout ... n_id=38580

You really should not be hitting your limit - that is a sign something is wrong.
I would consider a different host before VPS, but it is difficult to know without at least a link.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by paulfeakins » Wed Jul 09, 2025 6:04 pm

mandom wrote:
Wed Jul 09, 2025 5:27 pm
**max\_user\_connections** limit on my MySQL database.

...

* **Hosting**: Shared hosting with a 20 DB connection limit.
You need hosting with higher limits.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by johnp » Wed Jul 09, 2025 6:06 pm

mandom wrote:
Wed Jul 09, 2025 5:27 pm
Hi everyone,

I'm running OpenCart 3.0.4.0 on PHP 8.3 on shared hosting, and I'm encountering an issue with hitting the **max\_user\_connections** limit on my MySQL database. This error occurs around once a day, regardless of the time of day.

### Error Log:
```
[08-Jul-2025 17:00:02 UTC] PHP Fatal error: Uncaught Exception: Error: Could not connect to the database.<br>Error No: 1203<br>Message: User pattayak_newXXX already has more than 'max_user_connections' active connections in /home/pattayak/public_html/system/library/db/mysqli.php:13
Stack trace:
#0 /home/pattayak/storage3040/modification/system/library/db.php(36): DB\MySQLi->__construct()
#1 /home/pattayak/public_html/system/framework.php(83): DB->__construct()
#2 /home/pattayak/public_html/system/startup.php(104): require_once('/home/pattayak/...')
#3 /home/pattayak/public_html/index.php(19): start()
#4 {main}
thrown in /home/pattayak/public_html/system/library/db/mysqli.php on line 13
```

### Site and Hosting Details:

* **Traffic**: Around 100 visitors per day.
* **Installed Modules**: 20 modules.
* **Cron Jobs**: 5 cron jobs (non-overlapping, scheduled at different times).
* **Hosting**: Shared hosting with a 20 DB connection limit.

### Actions Taken:

1. Optimized cron jobs to ensure they don't overlap.
2. Considered changing session storage from database to file-based to reduce database load. I've read that this can potentially reduce connections by 50-60%. Is this true?
3. I'm currently running the site with fairly light traffic, so I'm not sure why it's hitting the DB connection limit.

### Question:

Is upgrading to a VPS the only solution, or is there another way to reduce the database connections without moving to a VPS? For example, will switching to file-based sessions make a significant difference?

I would appreciate any insights or suggestions on how to resolve this issue.

Thanks in advance for your help!
Try installing Cidram first. It will block a lot of undesirable traffic and help take the load off of your site.

https://github.com/CIDRAM/CIDRAM

Also as Paul says you need to look at better hosting.

Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD lover, user and geek.
Affordable Service £££ - Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
FREE Guidance and Advice at https://www.ecommerce-help.co.uk


User avatar
Active Member

Posts

Joined
Fri Mar 25, 2011 10:25 am
Location - Surrey, UK

Post by ADD Creative » Wed Jul 09, 2025 6:10 pm

Check your access log around the time of the errors to see what sort of requests you are receiving.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by mandom » Wed Jul 09, 2025 6:16 pm

by mona wrote:
Wed Jul 09, 2025 5:58 pm
1. If you have category count on - turn it off in settings and see if that helps.
2. Maybe a link to your site - Themes and extensions could be an issue.
3. Have you looked into different hosting?
4. Try a session debloater like this one for example https://www.opencart.com/index.php?rout ... n_id=38580

You really should not be hitting your limit - that is a sign something is wrong.
I would consider a different host before VPS, but it is difficult to know without at least a link.


Forgot to tell im using journal 3 theme

So for nr
1. I dont have many products about 40 products and 8 categorues this should not be a isssue.
2. Maybe a link to your site - Themes and extensions could be an issue. You mean External link? Not sure here.
3. Yes i have talked with many hosting. but they al have same on shared hosting. 20-30db connections limit. Siteground offer 500 DB connections on share server but then they its shared on al users.. and there first year is good price 8 usd per month then next year 49usd. so fishy . i dont want setup everyting again and then move server. so many setttings

4. 4. Try a session debloater like this one for example https://www.opencart.com/index.php?rout ... n_id=38580
this module is up to 3.0.3.7.. ------ 3 .0.3.8 and up this issue is fixed they say. so no need to use this.


i mean my site does not have so much traffic so i need VPS server .. just that DB connection hit userlimit some time. this really sucks.


What about changing Session to file instead of DB? in config.php. will this lower my DB connections?

New member

Posts

Joined
Tue Jun 30, 2015 4:44 pm

Post by mandom » Wed Jul 09, 2025 6:23 pm

ADD Creative wrote:
Wed Jul 09, 2025 6:10 pm
Check your access log around the time of the errors to see what sort of requests you are receiving.
What accses log are you refering to? Server level log? i dont have accses to that.

New member

Posts

Joined
Tue Jun 30, 2015 4:44 pm

Post by by mona » Wed Jul 09, 2025 6:28 pm

mandom wrote:
Wed Jul 09, 2025 6:16 pm
Forgot to tell im using journal 3 theme
This could definitely be causing you an issue.

mandom wrote:
Wed Jul 09, 2025 6:16 pm
1. I dont have many products about 40 products and 8 categorues this should not be a isssue.
Turn it off


mandom wrote:
Wed Jul 09, 2025 6:16 pm
2. Maybe a link to your site - Themes and extensions could be an issue. You mean External link? Not sure here.
A link to your website.
mandom wrote:
Wed Jul 09, 2025 6:23 pm
Server level log? i dont have accses to that.
If you host is not giving you access - change hosts
Not all hosts are the same even if the "figures" look better or worse.
mandom wrote:
Wed Jul 09, 2025 6:23 pm
What about changing Session to file instead of DB? in config.php. will this lower my DB connections?
Say a boat is taking in water. You need a pump, but you are asking if using a thimble will reduce the water level - yes, but it wont stop the boat from sinking !

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by ADD Creative » Wed Jul 09, 2025 6:33 pm

mandom wrote:
Wed Jul 09, 2025 6:23 pm
What accses log are you refering to? Server level log? i dont have accses to that.
The web access logs. In cPanel it's under Metrics as Raw Access.

Changing the session to file instead of db won't save a connections to the database as the request will still connect to the database for settings, etc. However if it was quicker then it may help as the connections will free up sooner, but it could also be slower.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by mandom » Wed Jul 09, 2025 6:42 pm

mandom wrote:
Wed Jul 09, 2025 6:23 pm
ADD Creative wrote:
Wed Jul 09, 2025 6:10 pm
Check your access log around the time of the errors to see what sort of requests you are receiving.
What accses log are you refering to? Server level log? i dont have accses to that.
I found the issue!! thanks.. after checking logs.
Tawkto chat widget is using Ai function to scan the hole site exakt same time. Creating 50-100 DB connectiojns same minut.. talking to there support now.

problem solved thank man!!

New member

Posts

Joined
Tue Jun 30, 2015 4:44 pm

Post by JNeuhoff » Wed Jul 09, 2025 7:39 pm

Glad to hear you managed to resolve it. Please add '[SOLVED]' to the beginning of the original forum thread title.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am

Who is online

Users browsing this forum: No registered users and 18 guests