A user reported to me seeing the following error on his screen: PDOException max_user_connections

The watchdog entry for this error looks like this:

PDOException: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction: INSERT INTO (.............)

I would like this kind of errors not to be displayed in detail on user screens.

However, I am not able to replicate this problem of displaying error in detail on the screen. During my tests, SQL errors are NOT displayed in detail at all. So, even if I apply a solution (like setting display_errors to FALSE in settings.php) I won't be able to test it, because I can't replicate this particular scenario which causes errors to be displayed on screen with details.

As part of the testing, I've made a deliberate mistake (in table name) in a database query in mymodule_node_view to test how such error will be visible on user screen. The problem is that in both cases, whether display_errors is turned "on" or "off" (checked on Site Status report: http://example.com/admin/reports/status/php), the result is identical. On user screen the error is displayed as:

enter image description here

It's not displaying any details, although in the watchdog log, it is similarly also a PDOException:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mydb.nodeaa' doesn't exist: SELECT (..............)

So, I don't understand. Why is Drupal displaying details of some PDOExceptions on user screen and not displaying details of some other PDOExceptions? How to effectively check whether a setting (e.g. display_errors set to "off") will fix the problem for all sorts of PDOException?

  • Similar question was posted here - if your concern is essentialy different somehow, please help me understand what you need that's not already there.
    – Mołot
    Commented May 20, 2013 at 8:55
  • Check this it will help you stackoverflow.com/questions/6000336/…
    – Bala
    Commented May 20, 2013 at 9:14
  • It will solve your issue stackoverflow.com/questions/8175850/drupal-sql-timeout-error
    – Bala
    Commented May 20, 2013 at 9:16
  • @Mołot - I have the "Error messages to display" already set to "None" in Drupal and some of the PDOExceptions are displayed despite of it (as in the first screenshot). Currently I need to prevent all PDOException to be seen by anybody (user, anonymous, admin) and maybe then I'll think how to show them only to admin, but that's not a priority.
    – camcam
    Commented May 20, 2013 at 10:08

1 Answer 1


The problem is - error that gets displayed means "Hey, I cannot connect to database! To many users already!". And the setting you are using to prevent error display are in database. And watchdog's log is in database. That's why Drupal shows it - it cannot know you set it not to, the very error prevents it from knowing. And even if it could, it cannot log it in any other way than to user's screen

To get this sorted out, you need two things:

  • And if you'll ask how to solve the sql 1203 state itself, if it wasn't asked here yet, I can provide quite a few pointers. Just not in this question, for clarity.
    – Mołot
    Commented May 20, 2013 at 11:58
  • 3
    This is working indeed! I managed to replicate this exact error on my local server and it threw all the details to the screen as before. Then I added to settings.php $conf['error_level'] = 0; and the error was gone from the screen. This post was also useful.
    – camcam
    Commented May 20, 2013 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.