502 Bad Gateway error after updating to Ghost 4.5

Hi everyone,

I’ve just updated my personal site (https://davidnge.com/) to Ghost 4.5 and I’ve been getting 502 Bad Gateway ever since.

Environment:

  • OS: Ubuntu, v16.04.6 LTS (Linode)
  • Node Version: v14.16.1
  • Ghost Version: 4.5.0
  • Ghost-CLI Version: 1.17.1

I’ve tried ghost restart and this was the error I’m seeing:

✔ Checking systemd unit file
✔ Checking systemd node version - found v14.16.1
+ sudo systemctl start ghost_davidnge-com
+ sudo systemctl stop ghost_davidnge-com
✖ Starting Ghost: davidnge-com
A GhostError occurred.

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

Debug Information:
    OS: Ubuntu, v16.04.6 LTS
    Node Version: v14.16.1
    Ghost Version: 4.5.0
    Ghost-CLI Version: 1.17.1
    Environment: production
    Command: 'ghost start'

Additional log info available in: /home/ghostex/.ghost/logs/ghost-cli-debug-2021-05-13T11_11_17_060Z.log

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

Tried ghost doctor but nothing’s wrong:

✔ Checking system Node.js version - found v14.16.1
✔ 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_davidnge-com
+ sudo systemctl reset-failed ghost_davidnge-com
✔ Validating config
✔ 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 v14.16.1

Here’s the additional log after running ghost restart:

Debug Information:
    OS: Ubuntu, v16.04.6 LTS
    Node Version: v14.16.1
    Ghost Version: 4.5.0
    Ghost-CLI Version: 1.17.1
    Environment: production
    Command: 'ghost start'
Message: Could not communicate with Ghost
Suggestion: journalctl -u ghost_davidnge-com -n 50
Stack: Error: Could not communicate with Ghost
    at Server.<anonymous> (/usr/local/lib/node_modules/ghost-cli/lib/utils/port$
    at Object.onceWrapper (events.js:421:28)
    at Server.emit (events.js:315:20)
    at emitCloseNT (net.js:1659:8)
    at processTicksAndRejections (internal/process/task_queues.js:79:21)

I’ve also tried reverting to previous Ghost version but the problem persist.

Anything else I should try?

Usually bad gateway errors are due to problems with nginx. I wonder if running ghost setup nginx will help, or otherwise fiddling with the nginx settings.

edit: setting up nginx separately and updating + restarting the digitalocean droplet I had ghost installed on helped me (had a lot of errors with the one-step digitalocean ghost install)

Not quite, a bad gateway means nginx is working but can’t talk to the upstream server (Ghost in this case).

@david_nge if you check your Ghost instance’s logs you should hopefully find some details of why Ghost can’t start.

1 Like

@Kevin Thanks for the tip.

Seems like the error stem from not being able to remove the permission(Read labels) from role(Editor).

After I ran ghost run:

2021-05-13 14:10:20] INFO Ghost is running in production...
[2021-05-13 14:10:20] INFO Your site is now available on https://davidnge.com/
[2021-05-13 14:10:20] INFO Ctrl+C to shut down
[2021-05-13 14:10:20] INFO Ghost server started in 0.952s
[2021-05-13 14:10:20] WARN Database state requires migration.
[2021-05-13 14:10:21] INFO Creating database backup
[2021-05-13 14:10:21] INFO Database backup written to: /var/www/ghost/content/data/david-nge.ghost.2021-05-13-14-10-21.json
[2021-05-13 14:10:21] ERROR Cannot remove permission(Read labels) from role(Editor) - permission does not exist

Cannot remove permission(Read labels) from role(Editor) - permission does not exist

"OuterError: Unable to update nested relation."

Error ID:
    400

----------------------------------------

RollbackError: Cannot remove permission(Read labels) from role(Editor) - permission does not exist
    at RollbackError.KnexMigrateError (/var/www/ghost/versions/4.5.0/node_modules/knex-migrator/lib/errors.js:7:26)
    at new RollbackError (/var/www/ghost/versions/4.5.0/node_modules/knex-migrator/lib/errors.js:31:26)
    at /var/www/ghost/versions/4.5.0/node_modules/knex-migrator/lib/index.js:440:23
    at tryCatcher (/var/www/ghost/versions/4.5.0/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/var/www/ghost/versions/4.5.0/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/var/www/ghost/versions/4.5.0/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/var/www/ghost/versions/4.5.0/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/var/www/ghost/versions/4.5.0/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/var/www/ghost/versions/4.5.0/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/var/www/ghost/versions/4.5.0/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/var/www/ghost/versions/4.5.0/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/var/www/ghost/versions/4.5.0/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:461:21)

Error: Cannot remove permission(Read labels) from role(Editor) - permission does not exist
    at down (/var/www/ghost/versions/4.5.0/core/server/data/migrations/utils.js:174:23)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Object.down (/var/www/ghost/versions/4.5.0/core/server/data/migrations/utils.js:281:13)
    at async Object.down (/var/www/ghost/versions/4.5.0/core/server/data/migrations/utils.js:305:17)
    at async Object.down (/var/www/ghost/versions/4.5.0/core/server/data/migrations/utils.js:305:17)

[2021-05-13 14:10:21] WARN Ghost is shutting down
[2021-05-13 14:10:21] WARN Ghost has shut down
[2021-05-13 14:10:21] WARN Your site is now offline
[2021-05-13 14:10:21] WARN Ghost was running for a few seconds

I’m not sure what to make out of this error though, I can’t seem to find this issue in other forum threads and ghost issues.

Any thoughts?