# Ghost Backup Error - 502 Bad Gateway

**URL:** <https://forum.ghost.org/t/ghost-backup-error-502-bad-gateway/52588>\
**Category:** Self-hosting\
**Created:** [November 18, 2024, 7:58pm UTC](https://forum.ghost.org/t/ghost-backup-error-502-bad-gateway/52588 "2024-11-18T19:58:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arejay](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@arejay](https://forum.ghost.org/u/arejay)\
**Post date:** [November 18, 2024, 7:58pm UTC](https://forum.ghost.org/t/ghost-backup-error-502-bad-gateway/52588/1 "2024-11-18T19:58:54Z")

</div>

I am getting this error, 502 bad gateway, when trying to run the command:  
ghost backup

I can get to my site just fine.

```auto
✖ Backing up site
An error occurred.
Message: 'Response code 502 (Bad Gateway)'

Debug Information:
    OS: Ubuntu, v20.04.6 LTS
    Node Version: v16.20.2
    Ghost Version: 5.39.0
    Ghost-CLI Version: 1.26.1
    Environment: production
    Command: 'ghost backup'

```

I am doing this in prep for an upgrade.

Ghost Doctor reports no errors

```auto
✔ Checking system Node.js version - found v16.20.2
✔ 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_hbcufan-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.20.2

```

---

<div class="post-metadata">

**Author:** ![arejay](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@arejay](https://forum.ghost.org/u/arejay)\
**Post date:** [December 2, 2024, 5:08pm UTC](https://forum.ghost.org/t/ghost-backup-error-502-bad-gateway/52588/2 "2024-12-02T17:08:07Z")

</div>

I need help upgrading my site, but I keep getting this error message. The site is available, but I cannot run the backup command.

```auto
Debug Information:
    OS: Ubuntu, v20.04.6 LTS
    Node Version: v16.20.2
    Ghost Version: 5.39.0
    Ghost-CLI Version: 1.26.1
    Environment: production
    Command: 'ghost backup'
An error occurred.
Message: 'Response code 502 (Bad Gateway)'

Stack: HTTPError: Response code 502 (Bad Gateway)
    at EventEmitter.<anonymous> (/usr/lib/node_modules/ghost-cli/node_modules/got/source/as-stream.js:35:24)
    at EventEmitter.emit (node:events:513:28)
    at module.exports (/usr/lib/node_modules/ghost-cli/node_modules/got/source/get-response.js:22:10)
    at ClientRequest.handleResponse (/usr/lib/node_modules/ghost-cli/node_modules/got/source/request-as-event-emitter.js:155:5)
    at Object.onceWrapper (node:events:628:26)
    at ClientRequest.emit (node:events:525:35)
    at ClientRequest.origin.emit (/usr/lib/node_modules/ghost-cli/node_modules/@szmarczak/http-timer/source/index.js:37:11)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:693:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
    at TLSSocket.socketOnData (node:_http_client:534:22)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at TLSSocket.Readable.push (node:internal/streams/readable:228:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
Path: /ghost/api/admin/db/

```

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [December 2, 2024, 6:59pm UTC](https://forum.ghost.org/t/ghost-backup-error-502-bad-gateway/52588/3 "2024-12-02T18:59:17Z")

</div>

You may need to follow these directions:

> **[How to backup your self-hosted Ghost install - Ghost Developers](https://ghost.org/docs/faq/manual-backup/)**
>
> Find out how tobackup your self-hosted Ghost install using Ghost CLI, or by performing a manual backup.

HOWEVER, be warned that neither Ghost backup nor the manual route in this document actually produces a 100% backup. I did this recently, and wrote about it:

> **[I moved servers!](https://www.spectralwebservices.com/blog/i-moved-servers/)**
>
> It went ok... mostly. Read on for the gotchas.

TL;DR: You will lose your comments.
