Support » Fixing WordPress » Seemingly random error establishing a database connection

  • So I am running into a database error that I just can’t seem to figure out. The site runs fine 99% of the time, I have no problem adding posts and pages, but every once in a while I get a database error. Rebooting Apache from the command line (Ubuntu 12.04) fixes it and everything goes back to normal. Sometimes the error happens when I am actively working on the site, sometimes when I wake up in the morning it is already down. There is minimal traffic to my site right now.

    Everything I have found online points toward a wpconfig problem, but could this really be the case since I usually have zero problems publishing posts, adding media, pages, etc?

Viewing 5 replies - 1 through 5 (of 5 total)
  • If it’s intermittant and you can connect most times it’s not a problem with the wp-config.php file. It’s most likely to be something overloading the server and either breaking the conection to the database server from the web server, or it’s causing too many connections between the two. The only way to tell is to look at the logs of your site. You may not be able to see the logs that you need depending on your hosting provider, so if not ask them and see what they can find.

    Thread Starter cassius123

    (@cassius123)

    I should be able to see everything as it is my own digitalocean cloud server. I am, unfortunately, learning as I go with this, but I am a quick learner. What logs should I look at? I have noticed that my memory usage is very high, near 100% sometimes. Could that be the cause? Thanks for the response.

    You’d need to look at the Apache error logs first, then at the MySQL logs, and then maybe even the Apache access log. That’s where most of the info will be located.

    As far as the memory goes, I don’t normally use that as an indicator for things like this, mainly because most *nix varients use as much RAM as they can when they’re serving pages like this, so just looking at RAM use can be deceptive. The main figure that I’d go by is the server load as that’s a more accurate measure of what the server is doing.

    http://www.rackspace.com/knowledge_center/article/checking-system-load-on-linux

    Thread Starter cassius123

    (@cassius123)

    OK, so I found that some URL was hitting my server, scanning and causing a segfault in Apache. Blocked the access using iptables and we’ll see if that works. Thanks again.

    Thread Starter cassius123

    (@cassius123)

    Just in case someone else has this problem, it turned out mySQL was crashing for lack of memory. I installed and configured swap and haven’t encountered the error since.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Seemingly random error establishing a database connection’ is closed to new replies.