Multisite won't work on my website; I keep getting "error establishing database connection

I've tried twice to implement Multisite on my website. Every time I edit my wp-config and htaccess files with the code given on the network setup page, I receive an "Error establishing database connection" and I can't even log in to my site. I've heard WP has trouble converting existing sites to multisite if they're over a month old, but is there some workaround for that problem?

  • Patrick
    • Support Monkey

    Hi there @jacky_comforty@comforty.com

    Welcome to the forums, glad to have you aboard!

    Sites that are more than a month old must be set up as sub-domain networks. To do so though, you must add a wildcard subdomain in your cPanel (screenshot)

    Without that wildcard, you'll get all kinds of errors.

  • jacky_comforty@comforty.com
    • Design Lord, Child of Thor

    Thank you so much for your response, Patrick. I've added the wildcard subdomain, and now I'm looking at the code the network setup page is telling me to add to the wp-config file.
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    define('DOMAIN_CURRENT_SITE', 'xx.xx.xxx.xx');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);

    Why does it automatically define subdomain as false, and list my ip address as the current domain?

  • Patrick
    • Support Monkey

    Hi again @jacky_comforty@comforty.com

    Sorry for the delay here; I was away with family for awhile.

    It may be that your server configuration doesn't allow for subdomain installs.

    Have you tried installing as a sub-directory setup instead? Sub-directories are actually better for SEO as the main site inherits all the link juice from the sub-sites. :slight_smile:

  • jacky_comforty@comforty.com
    • Design Lord, Child of Thor

    Hi Patrick,
    Thanks for getting back to me. I initially tried to do a path-based install, but the results were disastrous. I found at the bottom of the "Before you Create a Network" page these lines:
    "You cannot choose Sub-directory Install (for a path-based network) if your existing WordPress installation has been set up for more than a month, due to issues with existing permalinks. (This problem will be fixed in a future version. See Switching network types for more information.)"

    I wouldn't mind switching it to path-based after installing as domain-based, but right now I can't make any progress at all. I've contacted support at hostgator, but they were unable to provide any insight.

    Now, I'm in a redirect loop with the site. Any advice?

  • Patrick
    • Support Monkey

    Hi again @jacky_comforty@comforty.com

    I hope you had a great weekend despite this issue!

    I just caught on to something you had asked earlier about the IP address in wp-config.

    That should be changed to the actual domain name like so:
    define('DOMAIN_CURRENT_SITE', 'yourdomainnamehere.com');

    You were likely setting things up while logged into your wp-admin using the direct IP, or the domain name hadn't yet fully resolved, which can take up to 48 hours.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.