Ghost blog running but I get http error 502 when trying to load it. I believe it is related with ownership of /content dir?

If you’re looking for some help, it’s important to provide as much context as possible so that people are able to assist you. Try to always mention:

  • What’s your URL? https://www.mifitnessfacil.com
  • What version of Ghost are you using?
    Ghost-CLI version: 1.11.0 Ghost version: 2.23.1 (at /var/www/ghost)
  • What configuration? production should I paste config.production.json content here?
  • What browser? all of them
  • What errors or information do you see in the console? 502 Bad Gateway
  • What steps could someone else take to reproduce the issue you’re having?
  1. ssh into my digital ocean server via ssh: ssh root@foobar.com

  2. Change to ghost-mgr user: sudo -i -u ghost-mgr

  3. go to ghost dir: `cd /var/www/ghost``

  4. I stop running server successfully ghost stop

  5. then I start it again: ghost start and get output:

    ✔ 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_mifitnessfacil-com
    ✔ Validating config
    ✔ Checking folder permissions
    ✔ Checking file permissions
    ✔ Checking content folder ownership
    ✔ Checking memory availability
    + sudo systemctl start ghost_mifitnessfacil-com
    ✔ Starting Ghost
    + sudo systemctl is-enabled ghost_mifitnessfacil-com
    Your admin interface is located at:
        https://www.mifitnessfacil.com/ghost/
    

7. I go to my website url (https://www.mifitnessfacil.com) and get 502 Bad Gateway
8. After trying many solutions and reading in internet I believe it might be related to ownership of dir  `content/` if I run `ls -la`:

    ```drwxrwxr-x 7 ghost-mgr ghost 4096 Jun  9 10:57 .
    drwxrwxr-x 4 root      root  4096 May 14 20:15 ..
    -rw-rw-r-- 1 ghost-mgr ghost  119 Sep 26 08:03 .ghost-cli
    drwxrwxr-x 8 ghost-mgr ghost 4096 Jul  7 09:34 .git
    -rw-rw-r-- 1 ghost-mgr ghost   83 Jun  9 10:57 .gitignore
    -rw-rw-r-- 1 ghost-mgr ghost  562 Sep 26 08:03 config.production.json
    drwxrwxr-x 8 ghost     ghost 4096 Jun  2 14:39 content
    lrwxrwxrwx 1 ghost-mgr ghost   30 Jun  9 10:57 current -> /var/www/ghost/versions/2.23.1
    drwxrwxr-x 2 ghost-mgr ghost 4096 Jun  9 10:57 node_modules
    -rw-rw-r-- 1 ghost-mgr ghost   27 Jun  9 10:57 package-lock.json
    drwxrwxr-x 4 ghost-mgr ghost 4096 Jun 20 10:21 system
    drwxrwxr-x 3 ghost-mgr ghost 4096 Jun  2 14:39 versions

As you can see content dir is not owned by ghost-mgr user. So I tried changing ownership:
sudo chown -R $USER content/

This changes ownership but then when I tried ghost stop I get:

+ sudo systemctl is-active ghost_mifitnessfacil-com
A SystemError occurred.

Message: Systemd process manager has not been set up or is corrupted.
Help: Run ghost setup linux-user systemd and try again.

Please help

Hey there! Oh dear that doesn’t seem right, have you tried running ghost doctor to see what comes up?

Hi @DavidDarnes, many thanks for response when running ghost doctor I get:

✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking operating system compatibility
✔ Checking for a MySQL installation
+ sudo systemctl is-active ghost_mifitnessfacil-com
Instance is currently running
ℹ Validating config [skipped]
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability

this doesn’t look good: ℹ Validating config [skipped]
do you need me to post content of config.production.json? (obviously without the sensitive data parts).

Ah I see. I think it is ghost that should own the content directory. Are you able to check the logs? And just to double check, the server is setup to run a Ghost install? How to install & setup Ghost on Ubuntu 16.04, 18.04, 20.04 or 22.04

Hi @DavidDarnes

Yes I own the website and server so have access to everything. Do you mean the logs at /var/www/ghost/content/logs?

In the past the website was running perfectly and worked in all browsers, but the other day I tried to ghost stop and ghost restart and after that it stopped working. And yes prerequisites are met :slight_smile:

Hi again @DavidDarnes so I tried some other options I had some warnings with locales/en.json (which I removed in the past), but I recreated the file and no longer get errors for current date at content/logs/ but after running ghost start and login the systemd unit with sudo journalctl -f --unit ghost_mifitnessfacil-com outputs:

Sep 27 10:46:37 fitness-ghost-droplet systemd[1]: Stopping Ghost systemd service for blog: mifitnessfacil-com...
Sep 27 10:46:37 fitness-ghost-droplet node[12343]: [2019-09-27 10:46:37] WARN Ghost has shut down
Sep 27 10:46:37 fitness-ghost-droplet node[12343]: [2019-09-27 10:46:37] WARN Your site is now offline
Sep 27 10:46:37 fitness-ghost-droplet systemd[1]: Stopped Ghost systemd service for blog: mifitnessfacil-com.
Sep 27 10:46:57 fitness-ghost-droplet systemd[1]: Started Ghost systemd service for blog: mifitnessfacil-com.
Sep 27 10:47:01 fitness-ghost-droplet node[12628]: [2019-09-27 10:47:01] INFO Ghost is running in production...
Sep 27 10:47:01 fitness-ghost-droplet node[12628]: [2019-09-27 10:47:01] INFO Your site is now available on https://www.mifitnessfacil.com/
Sep 27 10:47:01 fitness-ghost-droplet node[12628]: [2019-09-27 10:47:01] INFO Ctrl+C to shut down
Sep 27 10:47:01 fitness-ghost-droplet node[12628]: [2019-09-27 10:47:01] INFO Ghost boot 2.643s
Sep 27 10:47:01 fitness-ghost-droplet node[12628]: [2019-09-27 10:47:01] INFO Bootstrap client was closed.```

So does the install work without the en.json file? Is it the contents of the file that’s causing issues? Or possibly the permissions on it?

Hi @DavidDarnes thanks for coming again. So the problem wasn’t the en.json the blog is still not working. So I read somewhere to run ghost run instead of ghost start since it throws more info for debugging and when running ghost run I get:

The ghost run command is used by the configured Ghost process manager and for debugging. If you’re not running this to debug something, you should run ghost start instead.

[2019-10-03 13:28:37] INFO Ghost is running in production...
[2019-10-03 13:28:37] INFO Your site is now available on https://www.mifitnessfacil.com/
[2019-10-03 13:28:37] INFO Ctrl+C to shut down
[2019-10-03 13:28:37] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-10-03 13:28:37] WARN Tries: 0
[2019-10-03 13:28:37] WARN Retrying...
[2019-10-03 13:28:37] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-10-03 13:28:37] WARN Tries: 1
[2019-10-03 13:28:37] WARN Retrying...
[2019-10-03 13:28:38] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-10-03 13:28:38] WARN Tries: 2
[2019-10-03 13:28:38] WARN Retrying...
[2019-10-03 13:28:38] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-10-03 13:28:38] INFO Ghost boot 3.415s 

When I check the content/logs files I get:

//...
{"name":"Log","hostname":"fitness-ghost-droplet","pid":16930,"level":40,"msg":"Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED","time":"2019-10-03T13:28:37.703Z","v":0}
//...

Running sudo journalctl -f --unit ghost_mifitnessfacil-com I get:

Oct 03 13:23:54 fitness-ghost-droplet node[16741]: [2019-10-03 13:23:54] INFO Ghost is running in production...
Oct 03 13:23:54 fitness-ghost-droplet node[16741]: [2019-10-03 13:23:54] INFO Your site is now available on https://www.mifitnessfacil.com/
Oct 03 13:23:54 fitness-ghost-droplet node[16741]: [2019-10-03 13:23:54] INFO Ctrl+C to shut down
Oct 03 13:23:54 fitness-ghost-droplet node[16741]: [2019-10-03 13:23:54] INFO Ghost boot 2.671s
Oct 03 13:23:54 fitness-ghost-droplet node[16741]: [2019-10-03 13:23:54] INFO Bootstrap client was closed.
Oct 03 13:24:08 fitness-ghost-droplet systemd[1]: Stopping Ghost systemd service for blog: mifitnessfacil-com...
Oct 03 13:24:08 fitness-ghost-droplet node[16741]: [2019-10-03 13:24:08] WARN Ghost has shut down
Oct 03 13:24:08 fitness-ghost-droplet node[16741]: [2019-10-03 13:24:08] WARN Your site is now offline```

all points to the "bootstrap client". But can't find any solutions for this online.

This was solved in the CLI today:

For some reason, the port Ghost runs on differed from the NGINX port

1 Like

Solved here: Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED · Issue #1017 · TryGhost/Ghost-CLI · GitHub

1 Like