• Resolved mikesouthern55

    (@mikesouthern55)


    When www.ads-software.com blame the host, and the hosts blame wordpress; that doesn’t help.

    I have the error frequently, on multiple sites and with multiple hosts: Fatcow, Bluehost, Godaddy. Some use a local DB server, some use a remote DB server. A variety of host names are in effect.

    The only consistent factor is that the data in my wp-configs NEVER changes. Never. Not by me, not by anybody.

    If it’s a server issue, obviously the answer does not lie here. It is surprising that so many servers have so many issues. But I have run MySql servers for years and outside of WordPress, and outside of the DB server actually being down, I’ve not seen this error. Yet at the time the error is received the database is not down. Never. I can administer the DB, back it up, hit it through a non-WP script, at the same time as receiving the wordpress error message.

    The only common factor is wordpress itself, and I’d say that with so many thousands of people experiencing the same problem all over the place, isn’t this a big problem?

    Questions:
    * Is there a cache in effect when wordpress accesses wp-config? i.e. are the connection config data cached and if so could that cache fail?

    * There are many third party caches available. Do any of these impact the connection process?

    * Is database size an issue? Does the problem increase with size?

Viewing 15 replies - 1 through 15 (of 32 total)
  • Dear lord I would love this to be addressed because yes, I’ve had the same issue as you and I get the same blame game. Everybody points to the other person.

    Thread Starter mikesouthern55

    (@mikesouthern55)

    I just received the message again, and immediately ran a server-side script that pulled todays blog headlines from the DB and it did so instantly. I also accessed it with php-myadmin – so the database was not down and I could connect to it. That makes it a wordpress problem.

    I run wordpress 3.5.1 with WP Super Cache 1.2. I optimise regularly with WP-Optimize and the wp-config file is the same now as it ever was. My host for this site is Bluehost. The database host is localhost – mainly because it IS localhost.

    Reviewing my setups, there is one other factor; none of my sites have their own dedicated server. They are all shared by other customers of the host so it is possibly that periodic load gets too much. I can’t tell though.

    Does anybody have a dedicated server and still get the message?

    My DB is 68Mb and contains 12,000 posts. I don’t know how that relates to other wp sites – whether it’s excessive, average, or a lot smaller than a large professional site.

    My DB is 68Mb and contains 12,000 posts

    I would say, that you got tons of posts revisions.

    Thread Starter mikesouthern55

    (@mikesouthern55)

    no post revisions. i keep it optimised.

    But if he is cleaning his database, then that is getting rid of those revisions and so there shouldn’t be a problem there. But I’ve had this issue with a much smaller database, not sure about size but the site is at 1,951 posts. We clean out our revisions all the time.

    If your config settings are correct, it looks like it is a server side issue – especially if you are on shared hosting. Did you seek your host’s support? Checked CPU usage?

    Can you post the site URL that you have problems with?

    Krishna: If your config settings are correct, it looks like it is a server side issue – especially if you are on shared hosting.

    mikesouthern55: I can administer the DB, back it up, hit it through a non-WP script, at the same time as receiving the wordpress error message… the data in my wp-configs NEVER changes.

    Krishna, WordPress is failing to connect while two other systems are connecting successfully. If it were a server issue, then those other systems would not be able to connect. It is never those other systems that are failing to connect. It is only WordPress that is failing to connect. mikesourthern55 is not a mysql/php newbie feeling his way around. WordPress is falling off when nothing else is falling off. That implicates WordPress.

    If shared hosting were the issue, then other systems hitting the database or the database server would be affected, but that is not reported.

    Am I misunderstanding?

    danallenhouston,
    Let us not get into conclusions. Did you go through the entire thread? Some of the indicators and the size of the sites show the reason could be what I wrote above in dedicated environs with some hosts. And, it is not necessary that all the installations should behave the same way. Are you sure that they are identical?

    @mikesouthern55,

    Can you post the site URL that you have problems with?

    WordPress connects to it’s database using the standard PHP founction of mysql_connect(). If this fails to connect it means that somewhere along the line the Apache process that’s running PH can’t make a connection to the database server.

    If this is intermittent then it’s a hardware issue. It means that the connection cannot be made between Apache and MySQL at the exact time that the connection was requested. Saying that it must be WordPress because other things work when tried close to that time is not an arguement as a difference of milliseconds can get a connection back again. Another thing to remember is that most servers have limits on the amount of active connections that can be created to MySQL and blocks any new connections from being made. If your connection request comes at that time, it will be blocked ad you’ll get the error message. In a shared environment that limit can be surprisingly easy to hit, especially if another account hasn’t been coded correctly and is using more connections then it should be.

    There’s a reason that hosts say that it’s a WordPress issue and not a hardware issue – If it’s a WordPress issue they don’t have to support it or go looking through their server logs to try and find answers. The biggest reason for this is that most times it is a WordPress issue, and they are right, and for the very few times when it is a real hardware issue they will get around to investigating onyl if the customer keeps on complaining about it (I’ve seen this with issues that I’ve had with two hosting companies before).

    If shared hosting where the issue then yes, other accounts trying to connect at that time may also be affected, but you’ll never know about it because it’s not related to your account. Those people might complain also, but they might not.

    Saying that it must be WordPress because other things work when tried close to that time is not an arguement as a difference of milliseconds can get a connection back again.

    Thank you for responding with such an excellent explanation.

    How do you explain that the problem is observed only in WordPress and none of the other apps the thread starter uses on the same database? If the problem is caused by limited number of available connections, WordPress would not be the only application exhibiting the problem.

    WordPress connects to it’s database using the standard PHP founction of mysql_connect(). If this fails to connect it means that somewhere along the line the Apache process that’s running PH can’t make a connection to the database server.

    Is there any way the ‘Error establishing a database connection’ can be thrown besides a fail on mysql_connect()?

    @mikesouthern55, the error thrown on fail of mysql_connect should include all of the following. Can you verify this is what you are seeing?

    <h1>Error establishing a database connection</h1>
    <p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>%s</code>. This could mean your host's database server is down.</p>
    
    <ul>
    <li>Are you sure you have the correct username and password?</li>
    <li>Are you sure that you have typed the correct hostname?</li>
    <li>Are you sure that the database server is running?</li>
    </ul>
    <p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='https://www.ads-software.com/support/'>WordPress Support Forums</a>.</p>

    I can’t explain that because I don’t have access to the server. This is a problem that can only be solved by someone that has complete access to the server logs and stats looking for the problem and analysing the loads and processes when it happens. When you’re on a shared hosting server you just don’t deal with top-level support that can actually diagnose the issue first off, you have to go through anywhere from 1 to 5 levels of support staff that are all trained in giving you the most common answers so that the real issues can be dealt with only when they are proven (by the client) to be real issues.

    If you’re convinced that this is somehow a WordPress issue, how would you explain the connection working sometimes and not other times when it’s exactly the same code that’s in use in every case?

    danallenhouston and catacaustic,
    The discussion is going nowhere near the poster’s problem. He/she has not responded. Let us wait for it. And please stop arguments based on assumptions.

    If you’re convinced that this is somehow a WordPress issue, how would you explain the connection working sometimes and not other times when it’s exactly the same code that’s in use in every case?

    There are 3 places in WordPress 3.5.1 where the text “Error establishing a database connection” appears:

    1. wp-db.php, line 1149 (as above, previous post)
    2. ms-load, line 237
    3. functions.php, line 2753

    Maybe something is happening in ms-load or functions.php, unrelated to db connection, traceable to cache? I don’t know, still looking into it.

Viewing 15 replies - 1 through 15 (of 32 total)
  • The topic ‘Error establishing a database connection’ is closed to new replies.