I'm running Laravel Valet to get a simple WP local development environment. Strangely at some point wp-cli stops being able to do much and gives me a "Error establishing a database connection" with nearly everything.

mkdir test
cd test
wp core download
wp config --dbname=test-wp --dbuser=root

(test the site at test.test in my browser: works great)
wp plugin
Error: Error establishing a database connection
wp core
Error: Error establishing a database connection
wp db query "SHOW TABLES"
(works: lists all the tables)

wp-config.php (excerpt)
define( 'DB_NAME', 'cc-wp' );

/** MySQL database username */
define( 'DB_USER', 'root' );

/** MySQL database password */
define( 'DB_PASSWORD', '' );

/** MySQL hostname */
define( 'DB_HOST', '' );

Not sure what else to test here. What's frustrating is that the site is working, connecting to the database and even wp-cli can connect to the database via wp db query so what's going on with this other stuff?

  • The irony is that two days ago wp-cli was working fine; I was able to install and activate plugins etc. Then I had all sorts of PHP and composer / homebrew issues that needed to be dealt with. And now this.
    – Tom Auger
    Oct 4, 2021 at 17:37


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.