502 bad gateway when accessing my domain

I have an 502 bad gateway error when accessing www.<my_domain>/ghost
Ghost-CLI version: 1.24.0
Installed Ghost version: v5.28.0
Node.js version - found v16.17.0

I have followed this tutorial and my port numbers in my ghost’s config file and the proxy_pass in ghost site’s nginx configuration files match.

In /var/www/ghost/config.production.json I can see:
“port”: 2368,
“host”: “127.0.0.1”

In /etc/nginx/sites-available/<my_domain>.com-ssl.conf and /etc/nginx/sites-available/<my_domain>.com.conf - both have:
proxy_pass http://127.0.0.1:2368;

This is a fresh Ghost install, I have just added A-records and configured SSL with an email. My next step was to access www.<my_domain>/ghost to create an admin.

Also, here is the netstat -plotn output:

I’m a newbie in Ghost, please, help

Unless it’s below your cropped image, Ghost isn’t running. What’s the output of ‘ghost ls’ in the terminal window?

1 Like

@Cathy_Sarisky you are right, it’s not running. The image is not cropped.
This is the output of the ghost start:

+ sudo systemctl is-active <my_domain>
✔ Checking system Node.js version - found v16.17.0
✔ Ensuring user is not logged in as ghost user
 Checking if logged in user is directory owner
✔ Checking current folder permissions
+ sudo systemctl is-active ghost_<my_domain>
✔ Validating confi
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencie
✔ Checking systemd unit file
✔ Checking systemd node version - found v16.17.0
+ sudo systemctl start <my_domain>
+ sudo systemctl stop <my_domain>
✖ Starting Ghost: <my_domain>
A GhostError occurred.
Message: Ghost was able to start, but errored during boot with: Access denied for user 'root'@'localhost' (using password: YES)
Help: Unknown database error
Suggestion: journalctl -u ghost_<domain_name>-com -n 50

Debug Information:
    OS: Ubuntu, v22.04.1 LTS
    Node Version: v16.17.0
    Ghost Version: 5.28.0
    Ghost-CLI Version: 1.24.0
    Environment: production
    Command: 'ghost start'

the output of the ghost ls:

Right. This isn’t a gateway problem. This is a ‘ghost isn’t running’ problem. Your problem is right here:

Do you have the MySQL password wrong?

1 Like

@Cathy_Sarisky I have never set MySQL password and don’t remember the system asked me to. Only SSH keys. Is there a way to check if it is set?

It’s possible. It’s frankly a pain in the rear. If this is a fresh install, I’d start over! :)

1 Like

@Cathy_Sarisky I think it is because of the error during installation.
I install Ghost from the DigitalOcean Marketplace. The only input that was required from me so far is domain name. This is an error:

✔ Setting up "ghost" system user
✖ Setting up "ghost" mysql user

What are my next steps?

Also, right after self-installation process it tries to start and:

If it were me and this was a brand new droplet I didn’t have anything invested in, I’d spin up a new droplet and see if the one-click install ran correctly on the second try.

Then I’d hope for someone on the forum with more DO droplet experience than me to help out. :slight_smile:

1 Like

I’d do it this way, too. Deleting the droplet and trying again is going to be far easier and quicker than trying to debug this issue.

1 Like