Jump to content

Critical Error Could not connect to the database.

Recommended Posts



I'm getting the following error : 

Critical Error

Could not connect to the database.


Here is my configuration.php file


$license = 'WHMCS-SECRET';
$db_host = '';
$db_username = 'user';
$db_password = 'SECRET';
$db_name = 'mydb';
$cc_encryption_hash = 'jdhJSH4ze47qs5AZde45d5qsd4zesde44aDgfvfzZf';
$templates_compiledir = '/var/www/template_c/';
$attachments_dir = "/var/www/html/test/att";
$downloads_dir = "/var/www/html/test/att";
$customadminpath = 'admin';
$api_access_key = 'SECRET';

I tried to connect from the server to the database using the same credentials as in the file : 


mysql -h -u user -pSECRET mydb



MySQL [mydb]>

How can I debug it ?


PHP 7.0.33

Share this post

Link to post
Share on other sites

If you are connecting with Remote MySQL make sure your Server Firewall Accepts the Connections or use Localhost for connecting in same DB on the Server

Share this post

Link to post
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.

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.

  • Similar Content

    • By ModulesGarden
      1. cPanel Extended For WHMCS V3.10.0

      The grand new update of cPanel Extended For WHMCS has arrived embracing a string of new possibilities raised by the freshly implemented User Manager section! With it, your customers are empowered to create additional users along with their email, FTP, and web disk sub-accounts.

      What is more, we have established support for Remote MySQL and ModSecurity. The first one permits customers to add remote host addresses that will allow visitors to connect to the MySQL databases. The second feature is responsible for protection of your clients' domains - they are free to decide whether it should be enabled or not.

      Learn more about cPanel Extended For WHMCS 3.10.0!

      2. SMS Center For WHMCS V3.7.0

      It’s common knowledge that untroubled flow of information both internal and external-wise is essential for smooth business operation. However, it is the skill of effective communication with both your teams and customers no matter the time and place that makes it truly stand out.

      Our newly released SMS Center For WHMCS 3.7.0 will offer you the choice of 7 more SMS gateways! With this prominent update, you can also bound customers to re-validate their phone numbers, access the archive of SMS messages, serve new events such as "Invoice Activation" and "Order Paid Activation", as well as make bulk status updates of the approval messages.

      Look into a more extensive account of the newly implemented changes!

      3. Hetzner VPS For WHMCS V1.4.0

      Our Hetzner VPS For WHMCS is already known to many, but after today it is very likely to win the hearts of the entire WHMCS community! This well-thought-out solution responsible for bringing automation into provisioning and management of Hetzner servers has just been bolstered up with some further optimizations.

      The 1.4.0 version introduces widely requested support for user data and floating IP addresses, as well as dynamic generation of hostname. Moreover, your clients are about to enjoy the freedom of ordering backups as an addition to the virtual machines. The richer the offer, the better!

      Eager to learn more? Look into the remaining benefits listed neatly in the module′s changelog!

      4. Over the last weeks we have also released a greal deal of WHMCS V8.0 compatibility updates:
      Amazon EC2 For WHMCS - v1.2.2 Amazon Lightsail For WHMCS - v1.1.5 Client Profile Viewer For WHMCS - v1.7.2 DigitalOcean Droplets For WHMCS - v1.6.1 Enom Email For WHMCS - v1.3.7 Hosting Renewals For WHMCS - v3.2.4 InterWorx Extended For WHMCS - v1.0.9 OpenStack VPS & Cloud For WHMCS - v1.9.3 QuickBooks Desktop For WHMCS - v1.3.4 Payment Gateway Allocator For WHMCS - v1.1.13 SolidCP Extended For WHMCS - v3.4.2  

      Need Custom Software Development For Your Business?
      Get Your Free Quote Now! Specially for you we will adapt an application and its design to your own needs, create a new module or even a completely new system built from scratch!  
    • By Dimitra
      I recently started using the Email Marketer in order to send automatic emails to my clients about their product's next due date.
      My problem is although  I have configured everything (following the documentation) correctly but the emails are not sent.
      I have created a Demo client with one product and a Email Marketer rule to send email 1 day before the product's Next Due Date. I have configured the product to expire (next due date) tomorrow, the demo client's email is correct (I have tested it and i can send/receive emails), but I still don't get the Product Expiring email.
      Checking the logs, I found the following entries:
      Notification sending failed for Rule ID 1 - Error: No Recipients Found
      Created Invoice - Invoice ID: 123
      Automated Task: Starting Invoices
      As for the cron jobs, I have noticed the following:
      in 'Set Up -> Automation Settings, I see the message Cron Status OK, however in the System Health page, I see the error:
      The system cron does not appear to have completed successfully within the last 24 hours. Check your activity logs or learn more about enabling the cron in our documentation. 
      I don't know if the cron job messages are related to the email problem.
      System details:
      WHMCS v7.10.2
      PHP 7.3
      Any help solving  the automatic emails problem would be appreciated.
    • By ramf
      I have to types of client email addresses - a regular email address and an email address that starts with dontreply and then some numbers and the domain prifas.co.il - something like that: dontreply1267@psifas.co.il
      I want to remove the Email Notifications (all except the "Domain Emails - Registration/Transfer Confirmation & Renewal Notices" that I can't remove) from all of the dontreplyXXXX@psifas.co.il customers but not to remove them from any other customer.
      Can you please help me with the exact command I should use in phpMyAdmin in order to remove all the Email Notifications from the dontreplyXXXX@psifas.co.il customers and only from them?
    • By budiantoip
      I've been trying this for a couple days and stuck.
      I am trying to add a custom function in WHMCS, by creating a file `addstripecard.php`, the idea is based on a given customer token (something like `cus_1GPkTFJEegxX3y3c123456`) and then try to attach it to a card. The custom function is accessed from an API.
      First, I'm trying to access the Stripe library, by using these commands :
      $gateway = new \WHMCS\Module\Gateway();
      PS: the codes were taken from `https://github.com/WHMCSCare/WHMCS-7.8.0-decoded/blob/e7446479de49a28c8801d4c0c95f4cae22dcff33/modules/gateways/stripe/lib/StripeController.php`
      But, after running the above commands, I got this error message :
      FastCGI sent in stderr: "PHP message: [WHMCS Application] ERROR: TypeError: Argument 2 passed to WHMCS\Api\ApplicationSupport\Http\ResponseFactory::factory() must be of the type array, string given,
      called in /www/xxxxxx.xxx/billing/vendor/whmcs/whmcs-foundation/lib/Api/ApplicationSupport/Route/Middleware/HandleProcessor.php on line 0 
      and defined in /www/xxxxxx.xxx/billing/vendor/whmcs/whmcs-foundation/lib/Api/ApplicationSupport/Http/ResponseFactory.php:0
      Stack trace: #0 /www/xxxxxx.xxx/billing/vendor/whmcs/whmcs-foundation/lib/Api/ApplicationSupport/Route/Middleware/HandleProcessor.php(0): WHMCS\Api\ApplicationSupport\Http\ResponseFactory::factory(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest), '{"legacyGateway...') #1 /www/xxxxxx.xxx/billing/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/DelegatingMiddlewareTrait.php(0): WHMCS\Api\ApplicationSupport\Route\Middleware\HandleProcessor->_process(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest), Object(Middlewares\Utils\Delegate)) #2 /www/dat" while reading response header from upstream, client:, 
      server: xxxxxx.xxx, 
      request: "POST /billing/includes/api.php HTTP/1.1",
      upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:",
      host: "xxxxxx.xxx.net"
      Full codes:
      if (!defined("WHMCS")) {
          die("This file cannot be access directly!");
      function addStripeCard()
          // card parameters
          $cardNumber       = $_POST['cardnumber'];
          $cardExpiryDate   = $_POST['cardexpirydate'];
          $remoteToken      = $_POST['remotetoken'];
          $billingContactId = $_POST['billingcontactid'];
          $description      = $_POST['description'];
          $cardType         = $_POST['cardtype'];
          $cardStartDate    = $_POST['cardstartdate'];
          $cardIssueNumber  = $_POST['cardissuenumber'];
          $clientId         = $_POST['clientid'];
          try {
              $gateway = new \WHMCS\Module\Gateway();
              return json_encode($gateway);
          } catch (Exception $e) {
              $error = [
                  'result'  => 'error',
                  'message' => $e->getMessage(),
                  'file'    => $e->getFile(),
                  'line'    => $e->getLine(),
              return $error;
      try {
          $data = addStripeCard();
          $apiresults = $data;
      } catch (Exception $e) {
          $error = [
              'result'  => 'error',
              'message' => $e->getMessage(),
              'file'    => $e->getFile(),
              'line'    => $e->getLine(),
          $apiresults = $error;
      Does anyone have a clue on what's going on? I've tried googling many times, but couldn't find any answers.
    • By vpshove
      Hello, I have a question on how to connect to hosted website whmcs database on my local pc,
      I am using MySQL Workbench, MySQL Query Browser to connect to cPanel database.
      Usually for a normal website database I am able to connect peacefully, but for whmcs it's on the other way round.
      For WHMCS, I filled in the hostname based on ip, username, password, and database name correctly but still doesn't let me.
      Is there a specific encryption or accessibility to grant user to connect whmcs database?
      Thank you!
  • 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