The Dreaded Error Establishing Database Connection Message

I am getting the dreaded “Error Establishing Database Connection” message when I try to visit my newly uploaded site. I’m using WP Multisite and I have double and triple checked that the information in my wp-config file is accurate. I did a database wide “find and replace” function in DW before moving my site from my local server to my remote server and I imported the updated db file without any trouble. I logged in to phpmyadmin and checked the tables wp_options, wp_blog, and wp_site in my database and they all look correct. I’m really at a loss at what to do next. The url is stixyarn.com and I’m using Bluehost. Thank you for the help!

  • Mustafa
    • Syntax Hero

    Hiya,

    1) Check your .htaccess file,

    2) Be sure to enter mysql server correctly (maybe your hosting provider using another port, you can ask them)

    3) Download your sql database and try to find “localhost”

    Are you using any custom database class for your multisite?

  • Ynattirb
    • WPMU DEV Initiate

    I don’t know what to check for in my .htaccess file. Here is what it currently looks like.

    # BEGIN WordPress

    RewriteEngine On

    RewriteBase /

    RewriteRule ^index.php$ – [L]

    # uploaded files

    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

    # add a trailing slash to /wp-admin

    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]

    RewriteCond %{REQUEST_FILENAME} -d

    RewriteRule ^ – [L]

    RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]

    RewriteRule ^[_0-9a-zA-Z-]+/(.*.php)$ $1 [L]

    RewriteRule . index.php [L]

    # END WordPress

  • Hakan
    • The Incredible Smush

    Hi,

    I agree with Mustafa. Try to find localhost keyword in your DB. Your website is simply redirected to localhost.

    Also if you are using any redirection plugin, deactivate it. Or better, deactivate all plugins, e.g. by renaming plugins folder.

    Cheers,

    Hakan

  • Ynattirb
    • WPMU DEV Initiate

    Still working on the problem. I haven’t tried disabling the plugins yet. Gonna try that next. I did export my DB file and search for localhost and there’s nothing there. I’m not using any redirecting plugins so I don’t think the problem has to do with a plugin, but I’m gonna disable them to check.

    I agree that my website is just redirected to localhost, but for the life of me I just can’t find where :slight_frown:

  • Ynattirb
    • WPMU DEV Initiate

    Ok…. so I’m an idiot. When I did the “find and replace” function over the DB file, I typed stixyarn instead of stixyarn.com. Wow.

    But now when I go to the site, the home page shows up just fine but all the other pages still show the database error message and are redirecting to localhost. I can now access the backend of WP and everything there seems to be fine. Any suggestions on how to fix the problem? Thanks!!!!!

  • Ynattirb
    • WPMU DEV Initiate

    I did a blanket “find and replace” on the DB file before I imported it I have checked all the pertinent tables to make sure the url has been changed from localhost to the correct web address. It all looks fine. I have also exported the DB file and searched for localhost to make sure it wasn’t in there anywhere and the search doesn’t find any instances of localhost in the file.

    Here’s something else… when I change

    define( ‘SUBDOMAIN_INSTALL’, false );

    in my wp-config file from false to true, all of the pages on the main site work just fine, but the other blog on my multisite can not be found. Also, currently my secondary blog shows up on the install with all of the pages, but only the content is there without any of the css styles. I can not access the network admin or the secondary blog admin, but I can acces the back end of primary blog.

  • Ynattirb
    • WPMU DEV Initiate

    Thank you for all of your replies!

    Ok. After many hours searching through the wp codex I have managed to fix some of my problems. The main site is working fine and I can access the network dashboard now, but my subdirectory site is not showing any theme styles and I still can not access the backend of the sub site. It’s something in my .htaccess file isn’t it? Here is the content of my .htaccess file. Help!

    # BEGIN WordPress

    RewriteEngine On

    RewriteBase /

    RewriteRule ^index.php$ – [L]

    # uploaded files

    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

    # add a trailing slash to /wp-admin

    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]

    RewriteCond %{REQUEST_FILENAME} -d

    RewriteRule ^ – [L]

    RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]

    RewriteRule ^[_0-9a-zA-Z-]+/(.*.php)$ $1 [L]

    RewriteRule . index.php [L]

    # END WordPress

  • aecnu
    • WP Unicorn

    Greetings Ynattirb,

    Sorry for the delay in a reply here, it appears that the ticket system ate this ticket putting it into the ticket system abyss.

    I do not know if you got all your issues resolved yet, but here is a good htaccess file, the first line portion protects the wp-config from prying eyes:

    <files wp-config.php>
    order allow,deny
    deny from all
    </files>

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ - [L]

    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule . index.php [L]
    # END WordPress

    Please advise if you are still having the issue with the sub sites.

    Cheers, Joe

  • Timothy
    • Chief Pigeon

    Hey there, I hope all is well.

    Just checking in to see how things are going here, its been a short while since we heard from you.

    If you still need further help then please feel free to reopen this thread or create a new one.

    Take care and have a great day! :slight_smile: