WordPress Database Connection Error

Fixing the "mysqli_get_server_info(): Argument #1 ($mysql) must be of type mysqli, bool given" error

Error Analysis

The error occurs because WordPress is trying to get MySQL server information, but the database connection is failing (returning false instead of a valid MySQL connection object).

[14-Sep-2025 21:15:24 UTC] PHP Fatal error: Uncaught TypeError: mysqli_get_server_info(): Argument #1 ($mysql) must be of type mysqli, bool given in /home1/aurrukwj/public_html/wp-includes/class-wpdb.php:4136
Stack trace:
#0 /home1/aurrukwj/public_html/wp-includes/class-wpdb.php(4136): mysqli_get_server_info(false)
#1 /home1/aurrukwj/public_html/wp-content/plugins/woocommerce/packages/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php(455): wpdb->db_server_info()
#2 /home1/aurrukwj/public_html/wp-content/plugins/woocommerce/packages/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php(644): ActionScheduler_DBStore->get_query_actions_sql(Array, 'select')
#3 /home1/aurrukwj/public_html/wp-content/plugins/woocommerce/packages/action-scheduler/classes/abstracts/ActionScheduler_Store.php(131): ActionScheduler_DBStore->query_actions(Array)
#4 /home1/aurrukwj/public_html/wp-content/plugins/woocommerce/packages/action-scheduler/functions.php(415): ActionScheduler_Store->query_action(Array)
#5 [internal function]: as_has_scheduled_action('wc_schedule_pen...')
#6 /home1/aurrukwj/public_html/wp-content/plugins/woocommerce/src/Internal/BatchProcessing/BatchProcessingController.php(554): call_user_func('as_has_schedule...', 'wc_schedule_pen...')
#7 /home1/aurrukwj/public_html/wp-content/plugins/woocommerce/src/Internal/BatchProcessing/BatchProcessingController.php(86): Automattic\WooCommerce\Internal\BatchProcessing\BatchProcessingController->remove_or_retry_failed_processors()
#8 /home1/aurrukwj/public_html/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Internal\BatchProcessing\BatchProcessingController->Automattic\WooCommerce\Internal\BatchProcessing\{closure}('')
#9 /home1/aurrukwj/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#10 /home1/aurrukwj/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#11 /home1/aurrukwj/public_html/wp-includes/load.php(1304): do_action('shutdown')
#12 [internal function]: shutdown_action_hook()
#13 {main}
thrown in /home1/aurrukwj/public_html/wp-includes/class-wpdb.php on line 4136

Root Cause

The error happens during WordPress shutdown process when WooCommerce's Action Scheduler tries to check for scheduled actions, but the database connection has been lost or failed to initialize properly.

Database Connection Issues

Possible Causes

Primary Issue: Database connection is failing during WordPress shutdown process

Immediate Solutions

Solution 1: Check Database Credentials

1

Verify wp-config.php Settings

Check your WordPress configuration file for correct database credentials:

define('DB_NAME', 'your_database_name'); define('DB_USER', 'your_database_user'); define('DB_PASSWORD', 'your_database_password'); define('DB_HOST', 'localhost');
2

Test Database Connection

Create a test file to verify database connectivity:

<?php $link = mysqli_connect('localhost', 'your_database_user', 'your_database_password'); if (!$link) { die('Could not connect: ' . mysqli_error()); } echo 'Connected successfully'; mysqli_close($link); ?>

Solution 2: Increase PHP Limits

1

Add to wp-config.php

Increase memory limits to prevent exhaustion:

define('WP_MEMORY_LIMIT', '256M'); define('WP_MAX_MEMORY_LIMIT', '512M'); @ini_set('memory_limit', '512M'); @ini_set('max_execution_time', '300');

Solution 3: Fix Database Connection Handling

1

Add Connection Check

Add this to your theme's functions.php or a custom plugin:

add_action('shutdown', 'check_db_connection_on_shutdown', 0); function check_db_connection_on_shutdown() { global $wpdb; // Check if database connection is still valid if (!is_resource($wpdb->dbh) && !is_object($wpdb->dbh)) { // Prevent further database operations if connection is lost remove_all_actions('shutdown'); return; } // Test the connection if (!$wpdb->check_connection(false)) { // Connection failed, prevent further database operations remove_all_actions('shutdown'); } }

Immediate Recommendation

Start with Solution 1 to verify your database credentials, then implement Solution 3 to prevent the error from occurring during shutdown.

Advanced Solutions

Database Server Optimization

If the issue persists, consider these server-level optimizations:

Setting Recommended Value Purpose
max_connections 100-200 Increase MySQL connection limit
wait_timeout 60 Reduce connection idle time
max_allowed_packet 64M Handle larger database operations

WordPress Optimization

Optimize WordPress to reduce database load:

  1. Install a caching plugin (WP Rocket, W3 Total Cache)
  2. Optimize database tables regularly
  3. Limit post revisions in wp-config.php:
    define('WP_POST_REVISIONS', 5);
  4. Enable persistent database connections (if supported by your host)

WooCommerce Specific Fix

Since the error originates from WooCommerce's Action Scheduler, you can try disabling action scheduler processing during shutdown:

add_action('shutdown', 'disable_woocommerce_shutdown_actions', 1); function disable_woocommerce_shutdown_actions() { if (class_exists('ActionScheduler_DBStore')) { remove_all_actions('shutdown'); } }

Debugging Steps

Enable WordPress Debugging

Add these settings to your wp-config.php to get more information:

define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false); @ini_set('display_errors', 0);

Check Error Log

Examine your PHP error log for additional clues:

  1. Check /home1/aurrukwj/public_html/error_log
  2. Check your hosting provider's error log section
  3. Look for earlier errors that might have caused the connection issue

Test Database Connection Independently

Create a simple PHP script to test database connectivity:

<?php // Test database connection $mysqli = new mysqli("localhost", "DB_USER", "DB_PASSWORD", "DB_NAME"); // Check connection if ($mysqli->connect_error) { die("Connection failed: " . $mysqli->connect_error); } echo "Connected successfully"; // Check server version echo "Server version: " . $mysqli->server_info; $mysqli->close(); ?>

Important

After implementing any fixes, monitor your error logs to ensure the issue is resolved. If the problem persists, contact your hosting provider as it might be a server-level database issue.