Ghost restart "Could not communicate with Ghost"

I changed the url of my blog with ghost config url XXX and got:

Successfully set 'url' to 'XXX'
+ sudo systemctl is-active ghost_YYY
Ghost is running. Don't forget to run ghost restart to reload the config!

So I ran ghost restart. It hung for a few minutes and then I got

+ sudo systemctl is-active ghost_YYY
+ sudo systemctl restart ghost_YYY
+ sudo systemctl stop ghost_YYY
✖ Restarting Ghost
A GhostError occurred.

Message: Could not communicate with Ghost
Suggestion: journalctl -u ghost_YYY -n 50

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

Additional log info available in: /home/ghost-mgr/.ghost/logs/ghost-cli-debug-2023-06-15T18_08_17_490Z.log

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

ghost doctor shows no issues. The log file shows

Debug Information:
    OS: Ubuntu, v22.04.1 LTS
    Node Version: v16.17.0
    Ghost Version: 5.47.2
    Ghost-CLI Version: 1.24.0
    Environment: production
    Command: 'ghost restart'
Message: Could not communicate with Ghost
Suggestion: journalctl -u ghost_YYY -n 50
Stack: Error: Could not communicate with Ghost
    at Server.<anonymous> (/usr/lib/node_modules/ghost-cli/lib/utils/port-polling.js:91:20)
    at Object.onceWrapper (node:events:627:28)
    at Server.emit (node:events:513:28)
    at emitCloseNT (node:net:1820:8)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

(Since ghost is down, I’m getting 502 Bad Gateway at my site.)

My installation is on Digital Ocean through the official pre-packaged droplet.

journalctl -u ghost_YYY -n 50 says no entries.

Might be a dupe of 5.44.0 Could Not Communicate with ghost - #4 by TeslaCuil

Okay, the problem (diagnosed by trying ghost run) seems to be that I didn’t include the protocol (https://) in my url. I reset to my original url and was able to run ghost restart successfully!

But I’m still getting the 502 Bad Gateway errors. sudo tail -f /var/log/nginx/error.log shows me

2023/06/15 18:22:31 [error] 854#854: *785 connect() failed (111: Unknown error) while connecting to upstream, client: AAA, server: BBB, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:2368/", host: "CCC"

Dead ends:

✔ Checking system Node.js version - found v16.17.0
✔ 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 system compatibility
✔ Checking for a MySQL installation
+ sudo systemctl is-active ghost_writing-jdecampos-com
Instance is currently running
ℹ Validating config [skipped]
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking free space
✔ Checking systemd unit file
✔ Checking systemd node version - found v16.17.0

A possible solution from another post on the same issue:

I am not familiar with netstat but I do see this line in my netstat -plant output:

tcp 0 0 127.0.0.1:2369 0.0.0.0:* LISTEN 7829/node

I tried updating the port numbers in /etc/nginx/sites-enabled/XXX.conf and /etc/nginx/sites-enabled/XXX-ssl.conf from 2368 to 2369 and then restarting with ghost restart. Seems to have had no effect.

Ah—after restarting nginx (sudo systemctl restart nginx), success! No more 502s. What a relief.

This mysterious port change sure does look like a Ghost issue…

1 Like