Sub site domains giving database error before being mapped.

After pointing the sub site domain using the A record, I get "Error establishing a database connection" when visiting the domain.

I've recently changed my server configuration. Now using a load balancer. This seems to have happened after this but I'm not sure what the problem is.

The database works fine and is connected to the site without any problems. I've got plenty of sub sites already connected that work fine.

It only happens when the domain hasn't yet been mapped to the site and only pointed to the server. I should mention that I'm pointing the A record to the load balancer IP but I've also tried pointing directly to the server as well.

If I try to visit a subdomain that doesn't exist I get redirected to the signup page so that seems to be working just fine.

Also, after mapping the domain, it works correctly. Although domain mapping plugin shows "need revalidate" in health status. I also had to turn off the verify option as the domains wouldn't verify with it on.

Any ideas? What could be happening here?