Update break down the whole site

I have a ghost instance running on a Digital Ocean droplet. Today, I tried to update my Ghost instance to the recent 5.40.1 version. However, due to some issue, the update got stuck, and when I restarted the shell running ghost update, I was running the latest version.

However since I tried to update, my ghost website is not working, I am getting the 502 nginx error screen. Running ghost doctor shows no error.

I have tried to reboot the instance and ghost start. But this is also not working. Sometimes ghost start gets stuck show no progress and shows Starting Ghost: blog forever.

And after ghost start I get this error:

A GhostError occurred.

Message: Could not communicate with Ghost
Suggestion: journalctl -u ghost_blog-indexdaily-in -n 50

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

Additional log info available in: /home/ghost-mgr/.ghost/logs/ghost-cli-debug-2023-03-26T14_57_53_345Z.log

This is what I have found in the log file:

Debug Information:
    OS: Ubuntu, v22.04.1 LTS
    Node Version: v16.17.0
    Ghost Version: 5.40.1
    Ghost-CLI Version: 1.24.0
    Environment: production
    Command: 'ghost start'
Message: Could not communicate with Ghost
Suggestion: journalctl -u ghost_blog-indexdaily-in -n 50
Stack: Error: Could not communicate with Ghost
    at Server.<anonymous> (/usr/lib/node_modules/ghost-cli/lib/utils/port-polli>    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)

How can I get this issue resolved without losing my website and its data?

Update:
running journalctl -u ghost_blog-indexdaily-in -n 50 as suggest by ghost gives me this log:

Mar 26 15:12:33 blog-ghost node[5394]:     at Module.require (node:internal/mod>
Mar 26 15:12:33 blog-ghost node[5394]:     at require (node:internal/modules/cj>
Mar 26 15:12:33 blog-ghost node[5394]:     at bootGhost (/var/www/ghost/version>
Mar 26 15:12:33 blog-ghost node[5394]:     at Object.<anonymous> (/var/www/ghos>
Mar 26 15:12:33 blog-ghost node[5394]:     at Module._compile (node:internal/mo>
Mar 26 15:12:33 blog-ghost node[5394]:     at Object.Module._extensions..js (no>
Mar 26 15:12:33 blog-ghost node[5394]:     at Module.load (node:internal/module>
Mar 26 15:12:33 blog-ghost node[5394]:     at Function.Module._load (node:inter>
Mar 26 15:12:33 blog-ghost node[5394]:   code: 'MODULE_NOT_FOUND',
Mar 26 15:12:33 blog-ghost node[5394]:   requireStack: [
Mar 26 15:12:33 blog-ghost node[5394]:     '/var/www/ghost/versions/5.40.1/core>
Mar 26 15:12:33 blog-ghost node[5394]:     '/var/www/ghost/versions/5.40.1/ghos>
Mar 26 15:12:33 blog-ghost node[5394]:     '/var/www/ghost/versions/5.40.1/inde>
Mar 26 15:12:33 blog-ghost node[5394]:   ]
Mar 26 15:12:33 blog-ghost node[5394]: }
Mar 26 15:12:33 blog-ghost systemd[1]: ghost_blog-indexdaily-in.service: Deacti>
Mar 26 15:12:33 blog-ghost systemd[1]: ghost_blog-indexdaily-in.service: Schedu>
Mar 26 15:12:33 blog-ghost systemd[1]: Stopped Ghost systemd service for blog: >
Mar 26 15:12:33 blog-ghost systemd[1]: Started Ghost systemd service for blog: >
Mar 26 15:12:34 blog-ghost node[5430]: Love open source? We’re hiring JavaScrip>
Mar 26 15:12:34 blog-ghost node[5430]: https://careers.ghost.org
Mar 26 15:12:34 blog-ghost node[5430]: - Inspecting operating system
Mar 26 15:12:34 blog-ghost node[5430]: Error: Cannot find module '@tryghost/ver>
Mar 26 15:12:34 blog-ghost node[5430]: Require stack:
Mar 26 15:12:34 blog-ghost node[5430]: - /var/www/ghost/versions/5.40.1/core/bo>
Mar 26 15:12:34 blog-ghost node[5430]: - /var/www/ghost/versions/5.40.1/ghost.js
Mar 26 15:12:34 blog-ghost node[5430]: - /var/www/ghost/versions/5.40.1/index.js
Mar 26 15:12:34 blog-ghost node[5430]:     at Function.Module._resolveFilename >
Mar 26 15:12:34 blog-ghost node[5430]:     at Function.Module._load (node:inter>
Mar 26 15:12:34 blog-ghost node[5430]:     at Module.require (node:internal/mod>
Mar 26 15:12:34 blog-ghost node[5430]:     at require (node:internal/modules/cj>
Mar 26 15:12:34 blog-ghost node[5430]:     at bootGhost (/var/www/ghost/version>
Mar 26 15:12:34 blog-ghost node[5430]:     at Object.<anonymous> (/var/www/ghos>
Mar 26 15:12:34 blog-ghost node[5430]:     at Module._compile (node:internal/mo>
Mar 26 15:12:34 blog-ghost node[5430]:     at Object.Module._extensions..js (no>
Mar 26 15:12:34 blog-ghost node[5430]:     at Module.load (node:internal/module>
Mar 26 15:12:34 blog-ghost node[5430]:     at Function.Module._load (node:inter>
Mar 26 15:12:34 blog-ghost node[5430]:   code: 'MODULE_NOT_FOUND',
Mar 26 15:12:34 blog-ghost node[5430]:   requireStack: [
Mar 26 15:12:34 blog-ghost node[5430]:     '/var/www/ghost/versions/5.40.1/core>
Mar 26 15:12:34 blog-ghost node[5430]:     '/var/www/ghost/versions/5.40.1/ghos>
Mar 26 15:12:34 blog-ghost node[5430]:     '/var/www/ghost/versions/5.40.1/inde>
Mar 26 15:12:34 blog-ghost node[5430]:   ]
Mar 26 15:12:34 blog-ghost node[5430]: }
Mar 26 15:12:34 blog-ghost systemd[1]: ghost_blog-indexdaily-in.service: Deacti>
Mar 26 15:12:34 blog-ghost systemd[1]: ghost_blog-indexdaily-in.service: Schedu>
Mar 26 15:12:34 blog-ghost systemd[1]: Stopped Ghost systemd service for blog: >
Mar 26 15:12:34 blog-ghost systemd[1]: ghost_blog-indexdaily-in.service: Start >
Mar 26 15:12:34 blog-ghost systemd[1]: ghost_blog-indexdaily-in.service: Failed>
Mar 26 15:12:34 blog-ghost systemd[1]: Failed to start Ghost systemd service fo>

Considering ‘MODULE_NOT_FOUND’, your update process might not have gone smoothly.

Maybe your server used up available RAM during the update process, this led to the update getting stuck.

This error could be caused by incorrect permission of directories and files, incorrect path or really by the absence of some module.

There are reports of a similar issue here on the forum: Unable to start Ghost.

I believe that, if it was an error related to the permission of files and directories, the ghost doctor would have reported it.

You may be able to momentarily stop some non-essential services to complete your upgrade. (To get more free ram memory).

You can force the update to try to fix possible missing files:

ghost update --force

You can also go back to the previous version by running:

ghost update --rollback

Tip: I’m not sure if ghost does a backup before updating, but you can do that manually by running ghost backup.

You can read more about this in Update Ghost to the latest major version.

this solved the problem.