502 Bad Gateway for no reason

I am seeing a periodic 502 bad gateway error when loading my site:

https://tomba.io/blog/

ghost status

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org

┌──────────────────────────────────────────────────────────────────────────────────┐
│Warning: MySQL 8 will be the required database in the next major release of Ghost.│
│     Make sure your database is up to date to ensure forwards compatibility.      │
└──────────────────────────────────────────────────────────────────────────────────┘

+ sudo systemctl is-active ghost_localhost
┌───────────┬───────────────┬─────────┬──────────────────────┬────────────────────────┬──────┬─────────────────┐
│ Name      │ Location      │ Version │ Status               │ URL                    │ Port │ Process Manager │
├───────────┼───────────────┼─────────┼──────────────────────┼────────────────────────┼──────┼─────────────────┤
│ localhost │ /var/www/blog │ 5.89.0  │ running (production) │ https://tomba.io/blog/ │ 2368 │ systemd         │
└───────────┴───────────────┴─────────┴──────────────────────┴────────────────────────┴──────┴─────────────────┘
netstat -tuln | grep 2368

shows no thing

error] 1023518#1023518: *20328677 connect() failed (111: Connection refused) while connecting to upstream, client:

ghost restart

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org

┌──────────────────────────────────────────────────────────────────────────────────┐
│Warning: MySQL 8 will be the required database in the next major release of Ghost.│
│     Make sure your database is up to date to ensure forwards compatibility.      │
└──────────────────────────────────────────────────────────────────────────────────┘

+ sudo systemctl is-active ghost_localhost
✖ Restarting Ghost
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.

Debug Information:
    OS: Ubuntu, v22.04.4 LTS
    Node Version: v18.18.0
    Ghost Version: 5.89.0
    Ghost-CLI Version: 1.26.1
    Environment: production
    Command: 'ghost restart'

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

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




location /blog/ {
    proxy_pass http://127.0.0.1:2368;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    }

}


```cat  https___tomba_io_blog__production.error.log
{"name":"Log","hostname":"vmi2014836.contaboserver.net","pid":728830,"level":50,"version":"5.89.0","err":{"domain":"https://tomba.io/blog/","code":127,"message":"Command failed: npm -v\n/bin/sh: 1: npm: not found\n","context":"\"Checking for updates failed, your site will continue to function.\"","help":"\"If you get this error repeatedly, please seek help from https://ghost.org/docs/\"","stack":"Error: Command failed: npm -v\n/bin/sh: 1: npm: not found\n\n    at ChildProcess.exithandler (node:child_process:422:12)\n    at ChildProcess.emit (node:events:517:28)\n    at maybeClose (node:internal/child_process:1098:16)\n    at Socket.<anonymous> (node:internal/child_process:450:11)\n    at Socket.emit (node:events:517:28)\n    at Pipe.<anonymous> (node:net:350:12)"},"msg":"Command failed: npm -v\n/bin/sh: 1: npm: not found\n","time":"2024-09-04T10:54:42.486Z","v":0}
{"name":"Log","hostname":"vmi2014836.contaboserver.net","pid":728830,"level":50,"version":"5.89.0","err":{"domain":"https://tomba.io/blog/","message":"Worker for job \"update-check\" exited with code 1","stack":"Error: Worker for job \"update-check\" exited with code 1\n    at Worker.<anonymous> (/var/www/blog/versions/5.89.0/node_modules/bree/lib/index.js:419:40)\n    at Worker.emit (node:events:517:28)\n    at Worker.emit (node:domain:489:12)\n    at [kOnExit] (node:internal/worker:289:10)\n    at Worker.<computed>.onexit (node:internal/worker:209:20)"},"msg":"Worker for job \"update-check\" exited with code 1","time":"2024-09-04T10:54:42.506Z","v":0}```

Fixed

npm uninstall -g ghost-cli
npm install -g ghost-cli

sudo chown -R ghost:ghost /var/www/blog
sudo chmod -R 775 /var/www/blog

sudo chown -R ghost:ghost /var/www/blog/content/logs
sudo chmod -R 775 /var/www/blog/content/logs

sudo systemctl restart ghost_localhost.service

Monitor Systemd for Any Further Issues
sudo journalctl -u ghost_localhost.service -f