I've been through the following steps on a local instance of a Craft 3.x project:

  1. Followed Migrating from Craft Nitro to DDEV and got the instance running on DDEV
  2. Updated to latest version of Craft 3: 3.8.14
  3. Gone through all the Upgrading from Craft 3 checks
  4. Attempted to run the update to 4.0.0 with plugins
  5. Had a fail
  6. Reverted to 3.8.14 from backup

I've done steps 4 to 6 a few times and after looking at a couple of possible points of failure not got anywhere.

Now that I'm back at 3.8.14 I thought I'd try garbage collection with php craft gc and curiously I get:

Craft can’t connect to the database. Check your connection settings.

…even though my instance clearly can connect, as I can navigate around the Control Panel and make changes!

Which makes me wonder if there's something related blocking the upgrade to 4.x.

My config/db.php has standard ENV references:

return [
    'dsn' => App::env('DB_DSN') ?: null,
    'driver' => App::env('DB_DRIVER'),
    'server' => App::env('DB_SERVER'),
    'port' => App::env('DB_PORT'),
    'database' => App::env('DB_DATABASE'),
    'user' => App::env('DB_USER'),
    'password' => App::env('DB_PASSWORD'),
    'schema' => App::env('DB_SCHEMA'),
    'tablePrefix' => App::env('DB_TABLE_PREFIX'),

and my local .env has what I believe to be correct for ddev:


Where might I be going wrong?


I just ran ddev craft db/backup and that went fine with a new file in the reported location.

So clearly I have db connection!

  • 1
    When you ran garbage collection did you run it with ‘ddev craft gc’? Also, what happened when you “had a fail”?
    – CraftQuest
    Commented Jul 3, 2023 at 5:57
  • Oh, of course! That makes sense. Thanks. I'm not used to thinking natively in the command line. Now onto the next bit. Commented Jul 3, 2023 at 10:12

1 Answer 1


There was no weirdness going on (Thanks CraftQuest in the comments), just my lack of fluency in the command line and newbie status with DDEV leading me to think the problem was somehow to do with database connectivity ( in my context, ddev is my craft CLI ‘owner’, not php).

Looking more carefully at the error logged by composer update I could see that I had left useProjectConfigFile=false in my config/general.php and that was why the upgrade was not running: see leaving legacy settings in general.php will throw an error.

Once removed, composer update ran just fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.