Setting up existing WP site, seems to be a problem connecting to my DB because of advanced cache

Hi all-

I’m setting up a huge, hulking old website up on Local, and I think it’s going pretty well so far, but I’m having a problem connecting to the database. Although I can see the DB on Adminer, and it says “logged as root@localhost” the “Database” tab of the Local GUI shows “Unable to find DB_HOST in app/public/wp-config.php” and so on down the line for DB_NAME, DB_USER, AND DB_PASSWORD.

I copied over my .Env file, and it seems like wp-config.php should just be grabbing the appropriate login from there, but it’s not.

Any guidance would be appreciated.

Hey @benspr

Are you using a preferred site or a custom one?

By default WordPress’ wp-config.php file doesn’t load .env files, so you might need to do one of two things:

  1. Update the wp-config.php file to use ENV variables. So something like this: https://m.dotdev.co/secure-your-wordpress-config-with-dotenv-d939fcb06e24
  2. Update the wp-config.php to use the values that are auto generated by Local when a new site is created. You might need to create a new site, and copy all of the files over EXCEPT the wp-config.php and then manually merge any site specific tweaks to that file while still keeping the DB connection details.

Hope that makes sense!

– Ben