Welcome Guest, Not a member yet? Register   Sign In
Unable to connect to your database server using the provided settings.
#1

Hi,

I have database connection problem after restarted my server. When I try to load my website, it shows “Unable to connect to your database server using the provided settings”. However, this issue is not happens all the time, sometime page loads without any issue.

I have checked my db connection stings like hostname, dbname, username and password and everything is correct.

Below is the db connection setting which I am using.

$db['default']['hostname'] = xxxx.com';
$db['default']['username'] = ‘xxxx';
$db['default']['password'] = 'xxxxx';
$db['default']['database'] = 'xxxx';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['active_r'] = TRUE;
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

Also attached screenshot of error message with this.
Please help me in this.

Attached Files Thumbnail(s)
   
Reply
#2

(This post was last modified: 07-17-2015, 07:16 AM by mwhitney. Edit Reason: add another possibility )

Does this only happen after restarting the server? Is the database hosted on the same server, or is the database server being restarted at the same time? It could be that the web server is starting up faster than the database.

For a while, I had some transient DNS errors on my server's network which caused this to happen on my server (very rarely, but still...). I ended up replacing the hostname with my database server's IP address until someone could figure out what was wrong with the DNS server(s). Of course, in this case, it was just a temporary work-around and I had every reason to believe that my database server's IP address wasn't going to change in the foreseeable future.

I'd suggest looking through server logs, if possible, to see if you're running into a similar error. In my case, the database connection errors were logged, so I could match up the timestamps on my web server with timestamps in other logs to determine where other errors were occurring on the network.

Edit: Another possibility is that your database server might be configured to limit the number of active connections (especially from a given user), so it might refuse connections when it reaches the limit.
Reply
#3

Something you might try is to test that the host name is actually correct. If you have access to telnet, you can do
% telnet hostname 3306

Some hosting providers have you use localhost, and some use something like mysql.domainname.com. Anyway something to try. Have you tried contacting your hosting provider.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB