# 502 Bad Gateway

**URL:** <https://forum.ghost.org/t/502-bad-gateway/42478>\
**Category:** Installation\
**Created:** [November 5, 2023, 8:55pm UTC](https://forum.ghost.org/t/502-bad-gateway/42478 "2023-11-05T20:55:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![IvanM](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ivanm/32/24515_2.png) [@IvanM](https://forum.ghost.org/u/IvanM)\
**Post date:** [November 5, 2023, 8:55pm UTC](https://forum.ghost.org/t/502-bad-gateway/42478/1 "2023-11-05T20:55:38Z")

</div>

Self hosted, tried to update to the latest version, and all fell apart.

Latest error:

Message: Ghost was able to start, but errored during boot with: connect ECONNREFUSED ::1:3306  
Help: Unknown database error  
Suggestion: journalctl -u ghost\_bilbord-rs -n 50

Debug Information:  
OS: Ubuntu, v22.04.1 LTS  
Node Version: v18.18.2  
Ghost Version: 5.72.0  
Ghost-CLI Version: 1.25.3  
Environment: production  
Command: ‘ghost backup’

Need help.

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [November 5, 2023, 9:00pm UTC](https://forum.ghost.org/t/502-bad-gateway/42478/2 "2023-11-05T21:00:48Z")

</div>

Common recent report - you just upgraded to node 18, right? If so, check this thread:

> [@Upgrade ghost 5.71.0 with node 18, encountered error](https://forum.ghost.org/t/upgrade-ghost-5-71-0-with-node-18-encountered-error/42246/3):
>
> Yes, I have the same issue. Still can’t fix it. Mysql is running, nodejs is already the newest version (18.18.2-1nodesource1). Tried ghost setup, still no success

If that’s not it, I’d start by investigating whether mysql is running. But start with the link above. I’m betting that’s it, because I see Ghost trying to connect to the ipv6 address… which is a change from Node 16.

---

<div class="post-metadata">

**Author:** ![IvanM](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ivanm/32/24515_2.png) [@IvanM](https://forum.ghost.org/u/IvanM)\
**Post date:** [November 6, 2023, 8:32pm UTC](https://forum.ghost.org/t/502-bad-gateway/42478/3 "2023-11-06T20:32:56Z")

</div>

Hi,

No luck with 127.0.0.1.

Trying to run mysql but error occurs:  
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO).

I also think that mysql is not running.

---

<div class="post-metadata">

**Author:** ![jeff](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/jeff/32/4900_2.png) [@jeff](https://forum.ghost.org/u/jeff)\
**Post date:** [November 7, 2023, 2:02am UTC](https://forum.ghost.org/t/502-bad-gateway/42478/4 "2023-11-07T02:02:43Z")

</div>

Looks like a root+mysql password error? You can run `sudo mysql -p` to get it to ask for the root password.

You can also look in the `config.production.json` for the user/password your blog is using to login to MySQL - and `mysql -u [ghost-user] -p` and enter the config password to confirm Ghost can connect to the db.

To see the status of MySQL `sudo systemctl status mysql` and check that it is Active.

To see if MySQL is actually running, `sudo netstat -leapn | less` shows all listening services on your host - if you see `127.0.0.1:3306` then MySQL is up and running.

---

<div class="post-metadata">

**Author:** ![IvanM](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ivanm/32/24515_2.png) [@IvanM](https://forum.ghost.org/u/IvanM)\
**Post date:** [November 7, 2023, 3:22am UTC](https://forum.ghost.org/t/502-bad-gateway/42478/5 "2023-11-07T03:22:10Z")

</div>

I have the acces and I tried with the pass, but still no:  
**-bash: syntax error near unexpected token `)’**

**sudo systemctl status mysql**  
● mysql.service - MySQL Community Server  
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)  
Active: active (running) since Sun 2023-11-05 20:24:29 UTC; 1 day 6h ago  
Process: 720 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)  
Main PID: 816 (mysqld)  
Status: “Server is operational”  
Tasks: 38 (limit: 2309)  
Memory: 435.4M  
CPU: 13min 38.881s  
CGroup: /system.slice/mysql.service  
└─816 /usr/sbin/mysqld

Nov 05 20:24:21 Bilbord systemd[1]: Starting MySQL Community Server…  
Nov 05 20:24:29 Bilbord systemd[1]: Started MySQL Community Server.

---

<div class="post-metadata">

**Author:** ![jeff](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/jeff/32/4900_2.png) [@jeff](https://forum.ghost.org/u/jeff)\
**Post date:** [November 7, 2023, 3:41am UTC](https://forum.ghost.org/t/502-bad-gateway/42478/6 "2023-11-07T03:41:28Z")

</div>

Did you see @Cathy_Sarisky post - that is most likely the issue.

I think they are saying to change “localhost” to “127.0.0.1” in the database section of your `config.production.json`

---

<div class="post-metadata">

**Author:** ![IvanM](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ivanm/32/24515_2.png) [@IvanM](https://forum.ghost.org/u/IvanM)\
**Post date:** [November 7, 2023, 9:55am UTC](https://forum.ghost.org/t/502-bad-gateway/42478/7 "2023-11-07T09:55:27Z")

</div>

It works!

I need it ro restart the Ghost and that is it.

Tnx a lot.
