I installed Docker and Nitro and successfully used nitro create <folder-name>, and ended up with the 'Welcome to Craft CMS!' message.

I cded into the new folder and invoked ./craft setup, which along the way has reported 'success!' at testing database credentials.

After saying yes to installing on the command line and creating an admin user account, I've received:

*** installed Craft successfully (time: 12.240s)

Generating project config files from the loaded project config ... done

I can see my new local dev instance running in Docker.app, but when I go to the site in a browser I get 503 – Service Unavailable.

If I go to {hostname}/admin I get the browser prompt to Install Craft. If I try and fill that out I get PDO exception: SQLSTATE[HY000] [2002] Connection refused.

The potential ease of use of Nitro looks really promising so it's frustrating to be so close!

What could I be missing?

Update 1

I have the following in my .env:


where <dbname> is the DB name I was asked to define (during nitro create I think) and which it said it could connect to.

Under 'Databases' nitro context reports:

  engine:        mysql 5.6      hostname: mysql-5.6-3306.database.nitro
  username:      nitro  password: nitro
  port:  3306

Update 2

To start from scratch, I junked my nitro instance in Docker and uninstalled nitro, and then reinstalled it, and went through nitro create again, and…

ended up in basically the same place.

I've tried my custom database name as the value of DB_DATABASE and the default nitro database name, and it makes no difference.

  • Did you edit your .env file or have Nitro do it for you? Your DB_* values need to reference the details you get for the relevant database engine running nitro context.
    – Matt Stein
    Commented Mar 16, 2021 at 14:45
  • Thanks Matt. Re the .env I did a combination of both I think. I have updated my question above with the current state. Commented Mar 16, 2021 at 14:57
  • 2
    Nitro should have updated .env so that DB_SERVER=mysql-5.6-3306.database.nitro in this case, not
    – Matt Stein
    Commented Mar 16, 2021 at 17:16
  • Ah, of course! So obvious now you point it out. That has worked thanks. Do you want to post it as an answer so I can vote for it? Commented Mar 16, 2021 at 17:24
  • Answered—thank you! :)
    – Matt Stein
    Commented Mar 16, 2021 at 20:11

1 Answer 1


After cheating via discussion in the comments, I’m certain that your DB_SERVER is incorrectly set to when it should in fact be mysql-5.6-3306.database.nitro.

In a perfect world this would have been set for you when Nitro edited .env, but in a pandemic-ravaged dystopia your next best option is to use whatever nitro context indicates.

  • FWIW the Craft starter project was tragically overwriting the .env Nitro likely set up for you with nitro create, which we’ve fixed. Should be smoother sailing going forward!
    – Matt Stein
    Commented Mar 16, 2021 at 22:00
  • Thanks for your help Matt :) Commented Mar 17, 2021 at 11:10

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.