502 Bad Gateway (111: Connection refused)

[Solved the original issue. See my reply for the continuing saga of the 502 bad gateway]
Hi - I’ve been trying to clean up what was once a multi-site hosting of ghost and is now only a site site hosting. I’m very nearly there, I think as I’ve fixed a whole heap of symlink issues and mysql problems. But I’m still getting a 502 Bad Gateway message which I’m fairly sure is some kind of permissions issue. Here’s the output from “ghost doctor”:

:heavy_check_mark: Checking system Node.js version
:heavy_check_mark: Checking logged in user
:heavy_check_mark: Ensuring user is not logged in as ghost user
:heavy_check_mark: Checking if logged in user is directory owner
:heavy_check_mark: Checking current folder permissions
System checks failed with message: ‘Linux version is not Ubuntu 16, 18, or 20’
Some features of Ghost-CLI may not work without additional configuration.
For local installs we recommend using ghost install local instead.
? Continue anyway? Yes [Note, system is Raspberry Pi"]
System stack check skipped
:information_source: Checking system compatibility [skipped]
:heavy_check_mark: Checking for a MySQL installation

  • sudo systemctl is-active ghost_corballis-co-uk
    :heavy_multiplication_x: Validating config
    :heavy_check_mark: Checking folder permissions
    :heavy_check_mark: Checking file permissions
    :heavy_check_mark: Checking memory availability
    :heavy_check_mark: Checking binary dependencies
    :heavy_check_mark: Checking free space
    One or more errors occurred.
  1. undefined

Error: EACCES: permission denied, open ‘/var/www/corballis.co.uk/.ghost-cli’
Debug Information:
OS: Raspbian GNU/Linux, v9
Node Version: v14.15.3
Ghost Version: 3.40.2
Ghost-CLI Version: 1.15.3
Environment: production
Command: ‘ghost doctor’

Try running ghost doctor to check your system for known issues.

You can always refer to https://ghost.org/docs/api/ghost-cli/ for troubleshooting.

OK… Solved by using touch to create the file

sudo touch .ghost-cli

Then used chown to change ownership

Now, if I run ghost start it hangs, but apparently does start because if ctl-c out of the command and do ghost ls then I get:

ame │ Location │ Version │ Status │ URL │ Port │ Process Manager │
├─────────────────┼──────────────────────────┼─────────┼──────────────────────┼─────────────────────────┼──────┼─────────────────┤
│ corballis-co-uk │ /var/www/corballis.co.uk │ 3.40.2 │ running (production) │ https://corballis.co.uk │ 2368 │ systemd

But, I still get the accursed Bad Gateway 502 error. A quick look at the nginx logs shows this:

2020/12/29 17:12:10 [error] 28046#28046: *78 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.105.120, server: corballis.co.uk, request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:2368/”, host: “corballis.co.uk
2020/12/29 17:12:11 [error] 28046#28046: *80 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.105.114, server: corballis.co.uk, request: “GET /favicon.ico HTTP/1.1”, upstream: “http://127.0.0.1:2368/favicon.ico”, host: “corballis.co.uk”, referrer: “https://corballis.co.uk/

As far as I can see, and I’ll admit to being pretty myopic, the hand off is correct being 127.0.0.1 on port 2368

Any clues? All gratefully received