Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Multi-Site and database connection errors WordPress

I have a site set up to use Multi-site wildcard subdomains.

It was working fine the other day.

The problem is that when I create a new subdomain site, everything appears to be successful and wordpress tells me the blog was created, but when I visit the URL to the new site, I get a standard,

"Error establishing database connection"

This doesn't make sense because it is using the same database as the main site. The main site works, I am able to create users, add content, etc...

I have ensured that the mysql user has all priviledges.

It makes absolutely no sense that only subdomain sites would cause the database connection error. Furthermore, sites that were previously created as subdomains are still working. It's only new sites that don't work.

I read somewhere that for multi-site you cannot have your main site with "www" in it. Is this true?

Answers (5)

2011-09-08

Reland Pigte answers:

Sub-domain sites work with the use of wildcard subdomains. This is a two-step process:

Apache must be configured to accept wildcards.
Open up the httpd.conf file or the include file containing the VHOST entry for your web account.
Add this line:
ServerAlias *.example.com

In the DNS records on your server, add a wildcard subdomain that points to the main installation. It should look like:
A *.example.com


Dan | gteh comments:

already done that.

ServerAlias *.mydomain.com already there.

DNS entry for *.mydomain.com as a CNAME to mydomain.com

As I mentioned, this was working previously and there are already 3 subdomain sites that are working just fine.

I am just unable to create any new ones as of today.

2011-09-08

Luis Abarca answers:

if you are using www.example.com

You should also add DNS entries in a similar manner.
*.www.example.com


Dan | gteh comments:

I dont think that's the issue.

HEre is a better explanation.

About 3 subdomains were created a few days ago and work.

SO this is the structure.

Main domain: www.example.com
Working subdomain: test.example.com
working subdomain: test2.example.com
working subdomain: anothertest.example.com

These above all work.

Today I tried to create a bunch more subdomains. They all appear in my 'All Sites' list however none are functional

Broken subdomain: test5.example.com

When visiting the broken subdomain, I get a standard, "Error establishing database connection"

Why would the first 3 subdomains work, but the 4th throws a database connection error

2011-09-08

fuscata answers:

Do you have the Defesio Anti-spam plugin installed? If so, disable it (I recommend moving the whole directory from wp-content/plugins to wp-content/plugins-disabled or similar), and try creating a new site.

2011-09-08

MDan answers:

Hello, check this thread, maybe will make you realize where the problem is:
http://premium.wpmudev.org/forums/topic/error-establishing-a-database-connection-with-multisite-configuration
In the bottom of the page is the solution for that problem, maybe it will help you also

2011-09-08

Gabriel Reguly answers:

Hi Dan,

This might be obvious, but did you added the sub domains to Domain Mapping?

http://example.com/wp-admin/network/settings.php?page=dm_domains_admin

I assume you are using WordPress MU Domain Mapping, correct?

Regards,
Gabriel