502 Bad Gateway error - Digital Ocean Ghost Droplet

We are a small charity running a website www.charnwoodsrc.org on a Digital Ocean droplet. I am not a developer, but the only Trustee that has very limited knowledge or Unix (from 30 years ago!).

Having received many warning about security, I have just updated Ghost to 6.24.0 from 4.48.9. Now when trying to access the website I get a 502 Bad Gateway error.

Any help trying to diagnose the problem would be greatly appreciated.

ghost-mgr@charnwood-web:/var/www/ghost$ ghost status

+ sudo systemctl is-active ghost_www-charnwoodsrc-org
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Name                 β”‚ Location       β”‚ Version β”‚ Status               β”‚ URL                          β”‚ Port β”‚ Process Manager β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ www-charnwoodsrc-org β”‚ /var/www/ghost β”‚ 6.24.0  β”‚ running (production) β”‚ https://www.charnwoodsrc.org β”‚ 2369 β”‚ systemd         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

ghost-mgr@charnwood-web:/var/www/ghost$ ghost doctor

:check_mark: Checking system Node.js version - found v22.22.2
:check_mark: Checking logged in user
:check_mark: Ensuring user is not logged in as ghost user
:check_mark: Checking if logged in user is directory owner
:check_mark: Checking current folder permissions
Warning: Your Ubuntu version has reached end-of-life.
Consider upgrading to Ubuntu 22.04 or 24.04.
:check_mark: Checking system compatibility
:check_mark: Checking for a MySQL installation

  • sudo systemctl is-active ghost_www-charnwoodsrc-org
    Instance is currently running
    :information_source: Validating config [skipped]
    :check_mark: Checking folder permissions
    :check_mark: Checking file permissions
    :check_mark: Checking content folder ownership
    :check_mark: Checking memory availability
    :check_mark: Checking binary dependencies
    :check_mark: Checking free space
    :check_mark: Checking systemd unit file
    :check_mark: Checking systemd node version - found v22.22.2

Ghost backup gives the following log

ghost-mgr@charnwood-web:/var/www/ghost$ cat /home/ghost-mgr/.ghost/logs/ghost-cli-debug-2026-04-01T11_02_40_883Z.log
Debug Information:
OS: Ubuntu, v20.04.6 LTS
Node Version: v22.22.2
Ghost Version: 6.24.0
Ghost-CLI Version: 1.28.6
Environment: production
Command: β€˜ghost backup’
An error occurred.
Message: β€˜Response code 502 (Bad Gateway)’

Stack: HTTPError: Response code 502 (Bad Gateway)
at EventEmitter. (/usr/lib/node_modules/ghost-cli/node_modules/got/source/as-promise.js:74:19)
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
Path: /ghost/api/admin/authentication/setup/

Ghost log

ghost-mgr@charnwood-web:/var/www/ghost$ ghost log

  • sudo systemctl is-active ghost_www-charnwoodsrc-org
    [2026-04-01 10:50:35] INFO Running milestone emails job on Wed Apr 01 2026 10:50:35 GMT+0000 (Coordinated Universal Time)
    [2026-04-01 10:50:35] INFO URL Service ready in 2275ms
    [2026-04-01 10:50:35] INFO Bootstrap client was closed.
    [2026-04-01 10:50:35] ERROR Could not get webhook secret for ActivityPub FetchError: invalid json response body at https://www.charnwoodsrc.org/.ghost/activitypub/v1/site/ reason: Unexpected token β€˜<’, "<!DOCTYPE "… is not valid JSON
    [2026-04-01 10:50:35] ERROR No webhook secret found - cannot initialise
    [2026-04-01 10:50:35] INFO Explore Response 200 OK
    [2026-04-01 10:51:39] INFO Updating incoming recommendations on boot
    [2026-04-01 10:53:49] INFO Worker for job β€œprocess-outbox” online
    [2026-04-01 10:53:49] INFO Worker for job process-outbox sent a message: done
    [2026-04-01 10:53:49] WARN Missing mail.from config, falling back to a generated email address. Please update your config file and set a valid from address
    [2026-04-01 10:53:49] INFO [OUTBOX] No pending outbox entries to process
    [2026-04-01 10:55:51] INFO [Recommendations] Updating recommendations metadata
    [2026-04-01 10:58:49] INFO Worker for job β€œprocess-outbox” online
    [2026-04-01 10:58:49] INFO Worker for job process-outbox sent a message: done
    [2026-04-01 10:58:49] WARN Missing mail.from config, falling back to a generated email address. Please update your config file and set a valid from address
    [2026-04-01 10:58:49] INFO [OUTBOX] No pending outbox entries to process
    [2026-04-01 11:03:49] INFO Worker for job β€œprocess-outbox” online
    [2026-04-01 11:03:49] INFO Worker for job process-outbox sent a message: done
    [2026-04-01 11:03:49] WARN Missing mail.from config, falling back to a generated email address. Please update your config file and set a valid from address
    [2026-04-01 11:03:49] INFO [OUTBOX] No pending outbox entries to process

ghost-mgr@charnwood-web:/var/www/ghost$ sudo systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2026-03-31 12:54:23 UTC; 22h ago
Process: 742 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 866 (mysqld)
Status: β€œServer is operational”
Tasks: 45 (limit: 1116)
Memory: 48.0M
CGroup: /system.slice/mysql.service
└─866 /usr/sbin/mysqld

Mar 31 12:54:15 charnwood-web systemd[1]: Starting MySQL Community Server…
Mar 31 12:54:23 charnwood-web systemd[1]: Started MySQL Community Server.

You probably have NGINX out in front as a reverse proxy. What do its logs say, and is it expecting Ghost at port 2369, or somewhere else?

@Cathy_Sarisky Thanks for the reply. It looks like port 2368

2026/04/01 13:14:46 [error] 849#849: *8022 connect() failed (111: Connection refused) while connecting to upstream, client: 78.153.140.93, server: www.charnwoodsrc.org, request: β€œGET /.env HTTP/1.1”, upstream: β€œhttp://127.0.0.1:2368/.env”, host: β€œ46.101.50.105”
2026/04/01 13:14:47 [error] 849#849: *8024 connect() failed (111: Connection refused) while connecting to upstream, client: 78.153.140.93, server: www.charnwoodsrc.org, request: β€œPOST / HTTP/1.1”, upstream: β€œhttp://127.0.0.1:2368/”, host: β€œ46.101.50.105”
2026/04/01 13:15:30 [error] 849#849: *8027 connect() failed (111: Connection refused) while connecting to upstream, client: 34.19.207.88, server: www.charnwoodsrc.org, request: β€œGET /pdown HTTP/1.0”, upstream: β€œhttp://127.0.0.1:2368/pdown”, host: β€œ46.101.50.105”
2026/04/01 13:16:21 [error] 849#849: *8029 connect() failed (111: Connection refused) while connecting to upstream, client: 43.130.53.252, server: www.charnwoodsrc.org, request: β€œGET / HTTP/1.1”, upstream: β€œhttp://127.0.0.1:2368/”, host: β€œ46.101.50.105”
2026/04/01 13:20:27 [error] 849#849: *8031 connect() failed (111: Connection refused) while connecting to upstream, client: 172.71.178.45, server: www.charnwoodsrc.org, request: β€œGET /internal-leagues/ HTTP/2.0”, upstream: β€œhttp://127.0.0.1:2368/internal-leagues/”, host: β€œwww.charnwoodsrc.org”
2026/04/01 13:20:31 [error] 849#849: *8033 connect() failed (111: Connection refused) while connecting to upstream, client: 172.68.229.42, server: www.charnwoodsrc.org, request: β€œGET /internal-leagues/ HTTP/2.0”, upstream: β€œhttp://127.0.0.1:2368/internal-leagues/”, host: β€œwww.charnwoodsrc.org”
2026/04/01 13:20:46 [error] 849#849: *8035 connect() failed (111: Connection refused) while connecting to upstream, client: 172.64.192.96, server: www.charnwoodsrc.org, request: β€œGET /internal-leagues/ HTTP/2.0”, upstream: β€œhttp://127.0.0.1:2368/internal-leagues/”, host: β€œwww.charnwoodsrc.org”
2026/04/01 13:22:44 [error] 849#849: *8037 connect() failed (111: Connection refused) while connecting to upstream, client: 185.16.39.146, server: www.charnwoodsrc.org, request: β€œGET / HTTP/1.1”, upstream: β€œhttp://127.0.0.1:2368/”, host: β€œ46.101.50.105”
2026/04/01 13:25:24 [error] 849#849: *8039 connect() failed (111: Connection refused) while connecting to upstream, client: 204.76.203.206, server: www.charnwoodsrc.org, request: β€œGET / HTTP/1.1”, upstream: β€œhttp://127.0.0.1:2368/”, host: β€œ46.101.50.105:80”

I changed the line β€œport”: 2369 to β€œport”: 2368 in /var/www/ghost/config.production.jsonto match the port in /etc/nginx/nginx.confand I can now access the website :sweat_smile: