# Ghost restart "Could not communicate with Ghost"

**URL:** <https://forum.ghost.org/t/ghost-restart-could-not-communicate-with-ghost/39225>\
**Category:** Developer help\
**Created:** [June 15, 2023, 6:17pm UTC](https://forum.ghost.org/t/ghost-restart-could-not-communicate-with-ghost/39225 "2023-06-15T18:17:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![loophole](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/loophole/32/24921_2.png) [@loophole](https://forum.ghost.org/u/loophole)\
**Post date:** [June 15, 2023, 6:17pm UTC](https://forum.ghost.org/t/ghost-restart-could-not-communicate-with-ghost/39225/1 "2023-06-15T18:17:09Z")

</div>

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

```auto
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

```auto
+ 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

```auto
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.

---

<div class="post-metadata">

**Author:** ![loophole](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/loophole/32/24921_2.png) [@loophole](https://forum.ghost.org/u/loophole)\
**Post date:** [June 15, 2023, 6:21pm UTC](https://forum.ghost.org/t/ghost-restart-could-not-communicate-with-ghost/39225/2 "2023-06-15T18:21:18Z")

</div>

`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](https://forum.ghost.org/t/5-44-0-could-not-communicate-with-ghost/37939/4)

---

<div class="post-metadata">

**Author:** ![loophole](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/loophole/32/24921_2.png) [@loophole](https://forum.ghost.org/u/loophole)\
**Post date:** [June 15, 2023, 6:45pm UTC](https://forum.ghost.org/t/ghost-restart-could-not-communicate-with-ghost/39225/3 "2023-06-15T18:45:49Z")

</div>

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

```auto
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:

- Per [How to update the URL of your self-hosted Ghost site](https://gloathost.com/blog/how-to-update-the-url-of-your-self-hosted-ghost-site/), I tried `ghost setup nginx` but got `Nginx configuration already found for this url. Skipping Nginx setup.`
- `ghost doctor` shows nothing interesting:

```auto
✔ 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](https://forum.ghost.org/t/502-bad-gateway-after-last-update/19294/7):

> [@502 bad gateway after last update](https://forum.ghost.org/t/502-bad-gateway-after-last-update/19294/8):
>
> In the error above, the port that the connection was trying to be established on was :2368 but doing a netstat -plant I saw that the correct port was :2369

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.

---

<div class="post-metadata">

**Author:** ![loophole](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/loophole/32/24921_2.png) [@loophole](https://forum.ghost.org/u/loophole)\
**Post date:** [June 15, 2023, 6:49pm UTC](https://forum.ghost.org/t/ghost-restart-could-not-communicate-with-ghost/39225/4 "2023-06-15T18:49:51Z")

</div>

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…
