Forums

MySQL exceeded the 'max_user_connections' error

Hello,

I had a script error yesterday whilst populating a table in MySQL and I now get the dreaded 'User has exceeded the 'max_user_connections' resource (current value: 3)' error whenever I try to connect.

I appreciate the error was on my part but I am now unable to connect to MySQL to kill whatever connections are dangling there and they do not appear to be timing out. From reading the forum it sounded like idle connections should time out after five minutes but the error occurred around 20 hours ago now and I still cannot reconnect.

Is there anything that can be done so I can regain access to MySQL?

Thank you!

That's very strange -- idle connections do indeed time out after five minutes. Are you sure you don't have code running somewhere (a scheduled task, a web app, or something) that's keeping them open somehow?

(BTW I just checked the database server you're on, and as of this writing you don't seem to have any open connections)

Hi Giles - There was definitely no code still running but at 24 hours post-crash the connections were suddenly all released. Bizarre, but I can access MySQL again so all is okay :-)

Hi there -- where do you access the DB from, eg. scheduled tasks/web apps/consoles/IPython notebooks? I'm wondering if somehow some of your code, which you'd thought you'd killed, was still running in some way that was hidden from you...

I suspect you're right, it does sound like there was some zombie process somewhere clinging onto my connections and preventing them timing out. I've wrapped my connection inside a context manager now so that if anything goes wrong it should disconnect gracefully and so far so good...