# Getting a 502 error

**URL:** <https://forum.ghost.org/t/getting-a-502-error/39975>\
**Category:** Using Ghost\
**Created:** [July 20, 2023, 1:03am UTC](https://forum.ghost.org/t/getting-a-502-error/39975 "2023-07-20T01:03:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PlayBox](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@PlayBox](https://forum.ghost.org/u/PlayBox)\
**Post date:** [July 20, 2023, 1:03am UTC](https://forum.ghost.org/t/getting-a-502-error/39975/1 "2023-07-20T01:03:38Z")

</div>

Previously I had an issue with node using ::1 instead of 127.0.0.1 to connect to my database. It was working but now getting a 502. The error log is reporting:

```auto
Jul 20 00:55:14 blog node[2292659]: {
Jul 20 00:55:14 blog node[2292659]: message: {
Jul 20 00:55:14 blog node[2292659]: statusCode: 500,
Jul 20 00:55:14 blog node[2292659]: errorType: 'DatabaseError',
Jul 20 00:55:14 blog node[2292659]: level: 'critical',
Jul 20 00:55:14 blog node[2292659]: message: 'Ghost was able to start, but errored during boot with: connect ECONNREFUSED ::1:3306',
Jul 20 00:55:14 blog node[2292659]: id: 500,
Jul 20 00:55:14 blog node[2292659]: help: 'Unknown database error',
Jul 20 00:55:14 blog node[2292659]: name: 'DatabaseError',
Jul 20 00:55:14 blog node[2292659]: code: 'ECONNREFUSED',
Jul 20 00:55:14 blog node[2292659]: property: null,
Jul 20 00:55:14 blog node[2292659]: redirect: null,
Jul 20 00:55:14 blog node[2292659]: hideStack: false,
Jul 20 00:55:14 blog node[2292659]: errno: -111,
Jul 20 00:55:14 blog node[2292659]: syscall: 'connect',
Jul 20 00:55:14 blog node[2292659]: address: '::1',
Jul 20 00:55:14 blog node[2292659]: port: 3306,
Jul 20 00:55:14 blog node[2292659]: fatal: true
Jul 20 00:55:14 blog node[2292659]: }
Jul 20 00:55:14 blog node[2292659]: }

```

DB config is still this:

```auto
  "database": {
    "client": "mysql",
    "connection": {
      "host": "127.0.0.1",
      "user": "strange",
      "password": "password!",
      "database": "strange_prod"
    }

```

Any suggestions?

---

<div class="post-metadata">

**Author:** ![PlayBox](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@PlayBox](https://forum.ghost.org/u/PlayBox)\
**Post date:** [July 20, 2023, 2:48am UTC](https://forum.ghost.org/t/getting-a-502-error/39975/2 "2023-07-20T02:48:02Z")

</div>

I tried to fix it by telling mysql to allow connections from ::1, and now it reports:

```auto
Jul 20 02:41:29 blog node[2372825]: {
Jul 20 02:41:29 blog node[2372825]: message: {
Jul 20 02:41:29 blog node[2372825]: statusCode: 500,
Jul 20 02:41:29 blog node[2372825]: errorType: 'DatabaseError',
Jul 20 02:41:29 blog node[2372825]: level: 'critical',
Jul 20 02:41:29 blog node[2372825]: message: "Ghost was able to start, but errored during boot with: Access denied for user 'root'@'localhost'",
Jul 20 02:41:29 blog node[2372825]: id: 500,
Jul 20 02:41:29 blog node[2372825]: help: 'Unknown database error',
Jul 20 02:41:29 blog node[2372825]: name: 'DatabaseError',
Jul 20 02:41:29 blog node[2372825]: code: 'ER_ACCESS_DENIED_NO_PASSWORD_ERROR',
Jul 20 02:41:29 blog node[2372825]: property: null,
Jul 20 02:41:29 blog node[2372825]: redirect: null,
Jul 20 02:41:29 blog node[2372825]: hideStack: false,
Jul 20 02:41:29 blog node[2372825]: errno: 1698,
Jul 20 02:41:29 blog node[2372825]: sqlState: '28000',
Jul 20 02:41:29 blog node[2372825]: sqlMessage: "Access denied for user 'root'@'localhost'"
Jul 20 02:41:29 blog node[2372825]: }
Jul 20 02:41:29 blog node[2372825]: }

```

Not sure why its trying to connect via root now

---

<div class="post-metadata">

**Author:** ![PlayBox](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@PlayBox](https://forum.ghost.org/u/PlayBox)\
**Post date:** [July 20, 2023, 2:58am UTC](https://forum.ghost.org/t/getting-a-502-error/39975/3 "2023-07-20T02:58:40Z")

</div>

I figured that part out, wrong config attempting to be ran.  
Nginx error log reports:

`2023/07/20 02:57:14 [error] 2189460#2189460: *771 connect() failed (111: Unknown error) while connecting to upstream, client: 162.121.245.100, server: enigmatic.zone, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:2368/", host: "enigmatic.zone"`

---

<div class="post-metadata">

**Author:** ![PlayBox](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@PlayBox](https://forum.ghost.org/u/PlayBox)\
**Post date:** [July 23, 2023, 10:54pm UTC](https://forum.ghost.org/t/getting-a-502-error/39975/4 "2023-07-23T22:54:41Z")

</div>

As I never got a response on even where to look for the issue, will be wiping the VPS and trying it again. This time will be using the Docker version
