Support » Fixing WordPress » Error establish database connection

  • Hey all,

    I have been working with a rather large blog and on a very random basis we get the error “Error establishing database connection” but if you immediately hit refresh, the site appears. This happens both on the public facing site and the WordPress admin area.

    I have read many other posts in the forum but none of them seem to be the same – they all seem to be that they couldn’t connect at all, whilst I can connect, however get this random message.

    I wonder if it could be anything to do with the number of database connections?

    I ran the site through Xenu this morning (checks all links and images are there) and at the same time viewing the process list in MySQL, and noticed that on many occassions the process count gets to 5 or 6. This is very light usage, and with the number of people probably viewing it as well it’s no more than 100 people at this time in the morning.

    I have increased the number of max connections allowed to MySQL and hope this will solve it, but I posted here just to see if anyone else has had the same issue.

    WordPress : 2.9.2
    Host : media temple
    MySQL Version : 5.0.77

    Thanks if you have any other suggestions.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator James Huff


    Halfelf Minion 🚀

    You’re on the right track. More than likely, the database server is either crashing under the load or cutting off the connections. Contact Media Temple if the problem continues.

    Thanks macmanx. I have done just that, and they have given me some awesome information to see what I can do to optimise things, so big props to Media Temple for this.

    Are there any other resources out there that could help me optimise speed up WordPress, as the blog owner wants his traffic to rise MASSIVELY over the next year with all his social networking and stuff he has planned.

    I have already informed him that once it goes get quite massive, serious investment in load balancing shenanigans will be required, but is there anything for the medium sized blogs that can be done?



    Moderator James Huff


    Halfelf Minion 🚀

    The best advice that I can offer anyone looking to start a high-traffic blog would be to:

    1. Don’t use unnecessary plugins. Keep your plugins at a minimum to avoid unnecessary load.

    2. Use a cache plugin, like W3 Total Cache, to reduce database queries.

    3. Keep your theme simple (nothing flashy and media-instensive) and valid.

    4. Use a tool like Web Page Analyzer to constantly check the load efficiency of your blog.

    5. Backup daily.

    Thanks for that.

    We have super cache running but still we are getting “Error establishing a database connection” – big plain no style, standard font page, and only those words, not even wrapped in a pretty error page.

    I have increase the max_connections to 500 in the my.cnf a while back so it surely can’t be using that number of connections?

    visitors : 175K unique
    pageviews: 350K+
    bandwidth: ~600GB easily.

    could it really be swallowing up the db connections?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Error establish database connection’ is closed to new replies.