Jump to content

Any Ideas - Connect to Database error


Dadss

Recommended Posts

Ok, before I ask, I have browsed the forums, and see really only 2 options for a critical error, can't connect to database. 1-is config.php is wrong, the other is the MySQL database.

 

I haven't changed the config.php since it was installed. It was working fine. Was out for a month or so, and now I can't connect. The MySQL seems fine. The config.php looks the same as when it was installed.

 

So my question is what else would cause it to not connect, and is there another option to fix it besides reinstalling?

 

Thanks fellas.

Link to comment
Share on other sites

  • 9 months later...

Please someone help?

 

I'm getting this same error critical error, can't connect to database and hoping to find a solution soon. I moved to Liquid Web hosting over 4 weeks ago and I've been having this problem every since the move.

 

My whmcs ran fine for 6 months on the old host. In this time whmcs has looked over my site and sent me to the host to ask them, then the host looks things over and sends me back to whmcs. This has been going round and round and getting nowhere while I lose sales for weeks now.

 

Sometimes the firefox browser will connect fine and most times in both the order side and in the admin and other times like now it does not. Customers call me and say they cant order or login because of the Critcal Error: could not connect to database.

 

Internet explorer seems to connect most of the time when testing an order but then tickets never show up in IE no matter what I click on, they only show in Firefox and everything functions fine in firefox, when it does connect.

 

I've reuploaded the files many times and checked configuration many times. My hosting support has checked thoroughly many times and has found no downtime in mysql or nothing in error logs. WHMCS has checked and sent me to the host on a few occasions.

 

The host has just sent me back here now.

 

Is there a list of settings I can give my host for a Linux VPS maybe? They have increased many settings already with no luck.

Link to comment
Share on other sites

Sometimes the firefox browser will connect fine and most times in both the order side and in the admin and other times like now it does not.

 

That sounds more like mysql is overloaded and refusing connections, as a bad config file would never connect. This can be from too many users, settings that don't allow enough connections or a myriad of other things.

Do you have access to post the my.cnf file for mysql to show how many connections are being allowed?

Link to comment
Share on other sites

Thank you for the helpful response. Here is my current my.cnf file. I do find that max_user_connections = 0 to be a little odd. FYI I do have many sites with lead capture pages connecting to a different database other then whmcs on my server to store web form results in. I don't know if this is also affecting things. Please tell me the best configuration for my.cnf. Thank you.

 

root@host [~]# cat /etc/my.cnf

[mysqld]

max_connections = 250

max_user_connections = 0

safe-show-database

skip-locking

key_buffer = 16M

max_allowed_packet = 1M

table_cache = 64

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 8M

wait_timeout = 30

query_cache_size=64M

table_cache=1024

old-passwords = 1

 

[mysqldump]

quick

max_allowed_packet = 16M

 

[mysql]

no-auto-rehash

 

[isamchk]

key_buffer = 20M

sort_buffer_size = 20M

read_buffer = 2M

write_buffer = 2M

 

[myisamchk]

key_buffer = 20M

sort_buffer_size = 20M

read_buffer = 2M

write_buffer = 2M

Link to comment
Share on other sites

Ok, I have finally narrowed down where the problem lies but I need your help to know where to go to fix it?

 

The Critical Error: Could not connect to database only occurs with me and all of my customers when there is a www. in the address anywhere in my support folder that my whmcs is installed under it does not occur when there is no wwww. in the address in this folder area.

 

Is this a WHMCS issue or a server issue?

 

Thanks very much.

Link to comment
Share on other sites

i have never heard of a www stopping a database call unless it is being treated differently by the vhost setup or dns. e.g. cant find the file.

 

what do your access/error logs look like?

 

You could also increase your max_connections setting to 300 and see if it clears it up.

Link to comment
Share on other sites

error logs don't show anything really. Further testing is showing that when I arrive at the error page and refresh/reload the page it does not help me to get me past the error. I then check my cookies listed for my domain in the Firefox browser. It shows several cookies including 2 PHPSESSID cookies. One is for http://www.mydomainname.com (my actual domain name) and one for mydomainname.com without the www. Both say expire at end of session. When I delete the PHPSESSID cookie corresponding to http://www.mydomainname.com because I am on a cart page that includes www. in the address bar, then refresh/ reload the error page. The error goes away and the cart page shows the way it should and I can continue through the order.

 

What tjis actually means or how to fix it. I don't know yet?

Link to comment
Share on other sites

One is for http://www.mydomainname.com (my actual domain name) and one for mydomainname.com without the www. Both say expire at end of session. When I delete the PHPSESSID cookie corresponding to http://www.mydomainname.com because I am on a cart page that includes www. in the address bar, then refresh/ reload the error page.

 

This doesn't sound right. If www is the correct URI, why are you deleting that cookie?

Perhaps you could force visitors to "www" using mod rewrite (if supported on your server) and that would resolve this. Create or edit your .htaccess file in the hosting account root (or just the WHMCS doc root) using the following.

 

The first example below would force www, the second would force it to not have it. Don't use them both at once, change it to your actual domain and make sure you test this. No guarantees. ;)

# non www -> www

Options +FollowSymlinks

RewriteEngine On

RewriteCond %{http_host} ^domain.com [NC]

RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

 

# www -> non www

Options +FollowSymLinks

RewriteEngine on

RewriteCond %{HTTP_HOST} .

RewriteCond %{HTTP_HOST} !^domain\.com

RewriteRule (.*) http://domain.com/$1 [R=301, L]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated