Setting database in config to run wp commands

Hi guys I am used to Local WP but am trying to make the switch so we can host our sites on Kinsta. My only drawback is I can’t run the wp acorn commands from my terminal in my theme file as it says it can’t make a database connection. I need this to use the log1x/acf-composer package. On Local WP I change the wp-config database to reference the php version from ‘details’ and point direct to the database.

Does anyone have a way to ensure I can run acorn commands and connect to the kinsta db?

Hi @jesswcd! Welcome to the Kinsta community!

Thank you for reaching out to us on the forums! I want to let you know we are investigating into this matter, and are attempting to replicate this issue on our end. We will be providing an update as soon as possible once we have more details to share.

In the meantime, if you do have any further information you’d like to share please feel free to reply!

Best regards

Hi @jesswcd!

We want to thank you for your patience while we investigated further into this matter. We have been performing testing internally to replicate the issue. After further investigation and tests we do see that it is possible to replicate this when the database configuration within the .env file is incorrect.

You will need to ensure that the database credentials are updated to match the expected values to establish a connection with the DevKinsta database Docker container. Please review your .env file database credentials to ensure that the username is set to “root” and that the password matches the value generated during the devkinsta_db container creation. A quick way to acquire this password would be to create a new site in DevKinsta and view the wp-config.php file created. This password can be used on your existing site with the Acorn installation.

You will also need to ensure that the DB_HOST value is set to devkinsta_db in the .env file.

Please let us know if this helps, or if you continue to have any difficulty with running the WP-CLI Acorn commands. We are standing by and more than happy to help!

Best regards

Hi @Andrew , thanks for looking into this. I do not have a .env I have the wp_config setting the host. Am I doing something wrong there? For terminal I am using Warp from the theme to run wp acorn. Composer is installed in the theme as well as I am not using Bedrock, just the plain Sage 10 theme.

/** Database username */
define( 'DB_USER', 'root' );

/** Database password */
define( 'DB_PASSWORD', '[PASSWORD]' );

/** Database hostname */
define( 'DB_HOST', 'devkinsta_db' );
wp acorn make:component Separator
Warning: mysqli_real_connect(): php_network_getaddresses: getaddrinfo for devkinsta_db failed: nodename nor servname provided, or not known in /Users/jess/DevKinsta/public/rhubarb-and-lavender/wp-includes/class-wpdb.php on line 1987
Warning: mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo for devkinsta_db failed: nodename nor servname provided, or not known in /Users/jess/DevKinsta/public/rhubarb-and-lavender/wp-includes/class-wpdb.php on line 1987
Error: `php_network_getaddresses: getaddrinfo for devkinsta_db failed: nodename nor servname provided, or not known`
Error establishing a database connection
This either means that the username and password information in your `wp-config.php` file is incorrect or that contact with the database server at `devkinsta_db` could not be established. This could mean your host’s database server is down.

Are you sure you have the correct username and password?
Are you sure you have typed the correct hostname?
Are you sure the database server is running?

If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress support forums. `php_network_getaddresses: getaddrinfo for devkinsta_db failed: nodename nor servname provided, or not known`

Hi @jesswcd ! :wave: That error reads like the database name is not correct for some reason :thinking:

Are you able to check the /Library/Application Support/DevKinsta/config.json file, and confirm that the database name listed there is the same as the one inside wp-config.php?

Hi @jackirish there is no DevKinsta directory in my application support. DevKinsta is in applications but there is nothing in /Library/Application Support/DevKinsta/config.json I have tried uninstalling and reinstalling and nothing changed.

Hey @jesswcd :wave:,
I am not able to replicate the issue on my side:

Can you please clarify the following:

  1. From which terminal are you running the command?
  2. Does any other wpcli command that makes checks to the db work? Please try wp db check --allow-root and let us know if you receive the same error

HI @Alessandro just to note, it is not within bedrock this is just the Sage theme on it’s own within the wp-content themes directory.

  1. I am running it through the Warp terminal.

Can you please try the same commands but within docker? Open docker, select the fpm container, then click on the terminal tab. Move to the right path of your installation and then perform the desired command (being sure to use --allow-root)