Can't activate plugin

After successful installation plugin activation fails with error:

Plugin could not be activated because it triggered a fatal error.

On remote hosting no issues, activation successful.

What could I do?

Have you been able to view the logs and see the fatal error? It might give a clue as to the issue. Some plugins require additional configuration for Local environments. You might check with the plugin authors or their documentation/forums for insight as well.

2 Likes

It’s worth double checking your WordPress version and PHP versions match your production environment.

You can also set debugging fully on in your local wp-config.php. This will activate the debug.log in your wp-content directory.

####
# For all your debugging needs
#
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY',true );

That should give you a stack trace in the log file. If not you can try some simple wpcli commands like wp plugin list to see what WordPress returns.

2 Likes

Got these errors:

[21-Jan-2025 13:39:19 UTC] PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000] [2002] Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte in C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\vendor\illuminate\database\Connectors\Connector.php:53
Stack trace:
#0 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\vendor\illuminate\database\Connectors\Connector.php(53): PDO->__construct('mysql:host=loca...', 'root', Object(SensitiveParameterValue), Array)
#1 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\vendor\illuminate\database\Connectors\Connector.php(34): IAWPSCOPED\Illuminate\Database\Connectors\Connector->createPdoConnection('mysql:host=loca...', 'root', 'root', Array)
#2 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\vendor\illuminate\database\Connectors\MySqlConnector.php(22): IAWPSCOPED\Illuminate\Database\Connectors\Connector->createConnection('mysql:host=loca...', Array, Array)
#3 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\vendor\illuminate\database\Connectors\ConnectionFactory.php(157): IAWPSCOPED\Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#4 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\vendor\illuminate\database\Connection.php(884): IAWPSCOPED\Illuminate\Database\Connectors\ConnectionFactory->IAWPSCOPED\Illuminate\Database\Connectors\{closure}()
#5 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\IAWP\Illuminate_Builder.php(98): IAWPSCOPED\Illuminate\Database\Connection->getPdo()
#6 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\IAWP\Illuminate_Builder.php(83): IAWP\Illuminate_Builder::disable_mariadb_optimization(Object(IAWPSCOPED\Illuminate\Database\MySqlConnection))
#7 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\IAWP\Illuminate_Builder.php(31): IAWP\Illuminate_Builder::make_connection()
#8 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\IAWP\Database.php(81): IAWP\Illuminate_Builder::new()
#9 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\IAWP\Database.php(25): IAWP\Database::user_privileges()
#10 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\IAWP\Database.php(21): IAWP\Database::missing_database_privileges()
#11 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\iawp-bootstrap.php(219): IAWP\Database::has_correct_database_privileges()
#12 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\iawp.php(64): require_once('C:\\Users\\orlov\\...')
#13 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-admin\includes\plugin.php(2387): include_once('C:\\Users\\orlov\\...')
#14 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-admin\includes\plugin.php(673): plugin_sandbox_scrape('independent-ana...')
#15 C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-admin\plugins.php(60): activate_plugin('independent-ana...', 'http://seikoman...', false)
#16 {main}
  thrown in C:\Users\orlov\Local Sites\billigerimmo\app\public\wp-content\plugins\independent-analytics\vendor\illuminate\database\Connectors\Connector.php on line 53

But the database is alive, fit and healthy - nothing beside this plugin has any issue with it.

@EvgeniyO Does it work if you edit your site’s wp-config.php to append the port number to your DB_HOST value?

See how to append your port number on Windows for an example.

It looks like this plugin may be trying to make a direct database connection instead of using the WordPress database API, and on Windows it could need the port number to do that.

2 Likes

@nickc If I hardcode the non-standard MySQL port in wp-config, what happens with the site after migration to linux remote host, where MySQL runs on standard 3306?

@EvgeniyO You could deploy without copying your wp-config.php to production, or set values conditionally if you really want to deploy wp-config.php.