<p>After cheating via discussion in the comments, I’m certain that your <code>DB_SERVER</code> is incorrectly set to <code>127.0.0.1</code> when it should in fact be <code>mysql-5.6-3306.database.nitro</code>.</p>
<p>In a perfect world this would have been set for you when Nitro edited <code>.env</code>, but in a pandemic-ravaged dystopia your next best option is to use whatever <code>nitro context</code> indicates.</p>

CC BY-SA 4.0
2021-03-16T22:00:59.513Z
FWIW the Craft starter project was tragically overwriting the `.env` Nitro likely set up for you with `nitro create`, [which we’ve fixed](https://github.com/craftcms/craft/releases/tag/1.1.3). Should be smoother sailing going forward!
Matt Stein
CC BY-SA 4.0
2021-03-17T11:10:06.840Z
Thanks for your help Matt :)
Jonathan Schofield
CC BY-SA 4.0
2021-03-16T20:10:57.200Z
2021-03-16T20:10:57.200Z
Matt Stein
<p>I installed Docker and Nitro and successfully used <code>nitro create &lt;folder-name&gt;</code>, and ended up with the 'Welcome to Craft CMS!' message.</p>
<p>I <code>cd</code>ed into the new folder and invoked <code>./craft setup</code>, which along the way has reported 'success!' at testing database credentials.</p>
<p>After saying yes to installing on the command line and creating an admin user account, I've received:</p>
<pre><code>*** installed Craft successfully (time: 12.240s)

Generating project config files from the loaded project config ... done
</code></pre>
<p>I can see my new local dev instance running in Docker.app, but when I go to the site in a browser I get <code>503 – Service Unavailable</code>.</p>
<p>If I go to <code>{hostname}/admin</code> I get the browser prompt to Install Craft. If I try and fill that out I get <code>PDO exception: SQLSTATE[HY000] [2002] Connection refused</code>.</p>
<p>The potential ease of use of Nitro looks really promising so it's frustrating to be so close!</p>
<p>What could I be missing?</p>
<hr />
<h3>Update 1</h3>
<p>I have the following in my <code>.env</code>:</p>
<pre><code>DB_DRIVER=mysql
DB_SERVER=127.0.0.1
DB_PORT=3306
DB_DATABASE=&lt;dbname&gt;
DB_USER=nitro
DB_PASSWORD=nitro
DB_SCHEMA=
DB_TABLE_PREFIX=
</code></pre>
<p>where <code>&lt;dbname&gt;</code> is the DB name I was asked to define (during <code>nitro create</code> I think) and which it said it could connect to.</p>
<p>Under 'Databases' <code>nitro context</code> reports:</p>
<pre><code>Databases:
  engine:        mysql 5.6      hostname: mysql-5.6-3306.database.nitro
  username:      nitro  password: nitro
  port:  3306
</code></pre>
<hr />
<h3>Update 2</h3>
<p>To start from scratch, I junked my nitro instance in Docker and uninstalled nitro, and then reinstalled it, and went through <code>nitro create</code> again, and…</p>
<p>ended up in basically the same place.</p>
<p>I've tried my custom database name as the value of <code>DB_DATABASE</code> and the default <code>nitro</code> database name, and it makes no difference.</p>

CC BY-SA 4.0
2021-03-16T14:45:25.253Z
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
CC BY-SA 4.0
2021-03-16T14:57:53.953Z
Thanks Matt. Re the `.env` I did a combination of both I think. I have updated my question above with the current state.
Jonathan Schofield
CC BY-SA 4.0
2021-03-16T17:16:16.700Z
Nitro should have updated `.env` so that `DB_SERVER=mysql-5.6-3306.database.nitro` in this case, not `127.0.0.1`.
Matt Stein
CC BY-SA 4.0
2021-03-16T17:24:44.757Z
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?
Jonathan Schofield
CC BY-SA 4.0
2021-03-16T20:11:37.200Z
Answered—thank you! :)
Matt Stein
CC BY-SA 4.0
2022-06-03T10:47:35.483Z
Heyy! I have the same Problem but i do have the right Database in the .env file. Any Suggestions?
Samuel Reichör
CC BY-SA 4.0
2022-06-03T13:06:19.080Z
Are you using Nitro?
James White
<nitro>
First steps with Craft Nitro: hostname not working after successful install
# First steps with Craft Nitro: hostname not working after successful install

(Asked by: username_0 on 2021-03-16)

I installed Docker and Nitro and successfully used nitro create , 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:
DB_DRIVER=mysql
DB_SERVER=127.0.0.1
DB_PORT=3306
DB_DATABASE=
DB_USER=nitro
DB_PASSWORD=nitro
DB_SCHEMA=
DB_TABLE_PREFIX=

where  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:
Databases:
  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.

**Tags:** nitro
> **Comments:**
> **username_1**: 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`.  
> **username_0**: Thanks Matt. Re the `.env` I did a combination of both I think. I have updated my question above with the current state.  
> **username_1**: Nitro should have updated `.env` so that `DB_SERVER=mysql-5.6-3306.database.nitro` in this case, not `127.0.0.1`.  
> **username_0**: 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?  
> **username_1**: Answered—thank you! :)  
> **username_2**: Heyy! I have the same Problem but i do have the right Database in the .env file. Any Suggestions?  
> **username_3**: Are you using Nitro?  

---

## 1 answers

### Answer by username_1 on 2021-03-16. Score: 3

After cheating via discussion in the comments, I’m certain that your `DB_SERVER` is incorrectly set to `127.0.0.1` 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.

> **Comments:**
> **username_1**: FWIW the Craft starter project was tragically overwriting the `.env` Nitro likely set up for you with `nitro create`, [which we’ve fixed](https://github.com/craftcms/craft/releases/tag/1.1.3). Should be smoother sailing going forward!  
> **username_0**: Thanks for your help Matt :)  

---

