# Migration Error - Upgrading Ghost from 3.x to 5.x

**URL:** <https://forum.ghost.org/t/migration-error-upgrading-ghost-from-3-x-to-5-x/31043>\
**Category:** Self-hosting\
**Created:** [June 28, 2022, 12:53pm UTC](https://forum.ghost.org/t/migration-error-upgrading-ghost-from-3-x-to-5-x/31043 "2022-06-28T12:53:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Connor\_Phillips](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@Connor\_Phillips](https://forum.ghost.org/u/Connor_Phillips)\
**Post date:** [June 28, 2022, 12:53pm UTC](https://forum.ghost.org/t/migration-error-upgrading-ghost-from-3-x-to-5-x/31043/1 "2022-06-28T12:53:49Z")

</div>

I am very behind on updating my ghost instance and started the process to update from version 3.0.2 (Mysql 5.7.38) to version 5.2.3. While I worked through that update, I had to run `ghost update v3` before being able to update to 5.2.3 and along the way updated my node. I have successfully updated to 5.2.3, but when restarting my ghost instance (`ghost restart`) I received a migration error.

What is strange about this migration error is that it suggests running `ghost update v3`, which doesn’t make sense because I’m on 5.2.3. Following the second suggestion, I ran `journalctl -u ghost_www-website-com -n 50` and saw a more verbose debug that pointed to the location of knex-migrator error, but no valuable information to work off of. I have seen some similar debug questions in the forum where it might have to do with collation name in the DB, but I’m not sure if that is the case for me.

Any direction would be helpful!

**Error:**

```auto
Debug Information:
    OS: Ubuntu, v18.04.3 LTS
    Node Version: v16.15.1
    Ghost Version: 5.2.3
    Ghost-CLI Version: 1.21.0
    Environment: production
    Command: 'ghost restart'
Message: Ghost was able to start, but errored during boot with: Unable to run migrations
Help: Run 'ghost update v3' to get the latest v3.x version, then run 'ghost update' to get to the latest.
Suggestion: journalctl -u ghost_www-website-com -n 50
Stack: Error: Ghost was able to start, but errored during boot with: Unable to run migrations
    at Server.<anonymous> (/usr/lib/node_modules/ghost-cli/lib/utils/port-polling.js:73:28)
    at Object.onceWrapper (node:events:641:28)
    at Server.emit (node:events:527:28)
    at emitCloseNT (node:net:1728:8)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

```

**journalctl -u ghost\_www-website-com -n 50**

```auto
    Unable to run migrations
Jun 28 12:42:08 website-com node[19796]: "You must be on the latest v3.x to update across major versions - https://ghost.org/docs/update/"
Jun 28 12:42:08 website-com node[19796]: "Run 'ghost update v3' to get the latest v3.x version, then run 'ghost update' to get to the latest."
Jun 28 12:42:08 website-com node[19796]: Error ID:
Jun 28 12:42:08 website-com node[19796]: b95aac70-f6df-11ec-9c81-5572693a5f7d
Jun 28 12:42:08 website-com node[19796]: ----------------------------------------
Jun 28 12:42:08 website-com node[19796]: InternalServerError: Unable to run migrations
Jun 28 12:42:08 website-com node[19796]: at /var/www/ghost/versions/5.2.3/node_modules/knex-migrator/lib/index.js:1032:19
Jun 28 12:42:08 website-com node[19796]: at up (/var/www/ghost/versions/5.2.3/core/server/data/migrations/utils/migrations.js:118:19)
Jun 28 12:42:08 website-com node[19796]: at Object.up (/var/www/ghost/versions/5.2.3/core/server/data/migrations/utils/migrations.js:54:19)
Jun 28 12:42:08 website-com node[19796]: at /var/www/ghost/versions/5.2.3/node_modules/knex-migrator/lib/index.js:982:33
Jun 28 12:42:08 website-com node[19796]: at /var/www/ghost/versions/5.2.3/node_modules/knex/lib/execution/transaction.js:221:22
Jun 28 12:42:08 website-com node[19796]: at processTicksAndRejections (node:internal/process/task_queues:96:5)

```

---

<div class="post-metadata">

**Author:** ![mjw](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/mjw/32/30781_2.png) [@mjw](https://forum.ghost.org/u/mjw)\
**Post date:** [June 28, 2022, 2:11pm UTC](https://forum.ghost.org/t/migration-error-upgrading-ghost-from-3-x-to-5-x/31043/2 "2022-06-28T14:11:43Z")

</div>

Did you update MySQL 5 first? You need to install MySQL 8 before updating to Ghost V5.

What’s the output from `ghost ls`?

---

<div class="post-metadata">

**Author:** ![Connor\_Phillips](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@Connor\_Phillips](https://forum.ghost.org/u/Connor_Phillips)\
**Post date:** [June 29, 2022, 12:23am UTC](https://forum.ghost.org/t/migration-error-upgrading-ghost-from-3-x-to-5-x/31043/3 "2022-06-29T00:23:45Z")

</div>

Originally that was my issue, but I was able to upgrade to MySQL 8 and re-ran hoping to see some success, but left with the same issue and errors at the migration

`ghost ls` **outputs** :

```auto
│ Name │ Location │ Version │ Status │ URL │ Port │ Process Manager │
├────────────────────────┼────────────────┼─────────┼─────────┼─────┼──────┼─────────────────┤
│ www-website-com │ /var/www/ghost │ 5.2.3 │ stopped │ n/a │ n/a │ n/a │
└────────────────────────┴────────────────┴─────────┴─────────┴─────┴──────┴─────────────────┘

```

**I ran** `ghost doctor`:

```auto
✔ Checking system Node.js version - found v16.15.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_www-connorphillips-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 v16.15.1

```

**Then** `ghost migrate`:

```auto
ghost migrate

✔ Checking for available migrations
No migrations needed :)

```

**Finally** `ghost restart`:

```auto
+ sudo systemctl is-active ghost_www-website-com
Ghost instance is not running! Starting...
+ sudo systemctl start ghost_www-website-com
+ sudo systemctl stop ghost_www-website-com
✖ Starting Ghost
A GhostError occurred.

Message: Ghost was able to start, but errored during boot with: Unable to run migrations
Help: Run 'ghost update v3' to get the latest v3.x version, then run 'ghost update' to get to the latest.
Suggestion: journalctl -u ghost_www-website-com -n 50

Debug Information:
    OS: Ubuntu, v18.04.3 LTS
    Node Version: v16.15.1
    Ghost Version: 5.2.3
    Ghost-CLI Version: 1.21.0
    Environment: production
    Command: 'ghost restart'

```

`mysql --version`:

`mysql Ver 8.0.29 for Linux on x86_64 (MySQL Community Server - GPL)`

---

<div class="post-metadata">

**Author:** ![Connor\_Phillips](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@Connor\_Phillips](https://forum.ghost.org/u/Connor_Phillips)\
**Post date:** [June 29, 2022, 1:05am UTC](https://forum.ghost.org/t/migration-error-upgrading-ghost-from-3-x-to-5-x/31043/4 "2022-06-29T01:05:49Z")

</div>

Maybe it has to do with the character set and collation name?

```auto
mysql> SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='ghost_production';
+----------------------------+------------------------+
| DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME |
+----------------------------+------------------------+
| latin1 | latin1_swedish_ci |
+----------------------------+------------------------+
1 row in set (0.00 sec)

```

**Update:**

I updated the values based on the forum responses to issues, but still seeing the same migration issues

```auto
mysql> SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='ghost_production';
+----------------------------+------------------------+
| DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME |
+----------------------------+------------------------+
| utf8mb4 | utf8mb4_general_ci |
+----------------------------+------------------------+
1 row in set (0.01 sec)

```

---

<div class="post-metadata">

**Author:** ![Connor\_Phillips](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@Connor\_Phillips](https://forum.ghost.org/u/Connor_Phillips)\
**Post date:** [June 29, 2022, 11:56am UTC](https://forum.ghost.org/t/migration-error-upgrading-ghost-from-3-x-to-5-x/31043/6 "2022-06-29T11:56:01Z")

</div>

I’ve started to follow the instructions to update to v3 before updating to v5.

```auto
Message: Unable to update Ghost directly to v3.42.9. You must be on the latest v5.x to update across major versions.
Help: Run "ghost update v5" to get the latest v5.x version, then run "ghost update" to get to v3.

```

It doesn’t make sense that I’m updating to v5, to update to v3, to update back to v5. Is it possible to install 3.42.9 while keeping 5.x? Or instructions to revert to 3.42.9 before going through the update process again?

---

<div class="post-metadata">

**Author:** ![mjw](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/mjw/32/30781_2.png) [@mjw](https://forum.ghost.org/u/mjw)\
**Post date:** [June 29, 2022, 12:18pm UTC](https://forum.ghost.org/t/migration-error-upgrading-ghost-from-3-x-to-5-x/31043/7 "2022-06-29T12:18:13Z")

</div>

Did you roll-back or restore a backup before starting over? If you have a mix of incompatible software versions, you’re going to run into difficulties.

I recommend you roll-back to the working V3 instances, and then follow the upgrade steps from the official documentation previously linked.

---

<div class="post-metadata">

**Author:** ![Connor\_Phillips](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@Connor\_Phillips](https://forum.ghost.org/u/Connor_Phillips)\
**Post date:** [June 29, 2022, 7:47pm UTC](https://forum.ghost.org/t/migration-error-upgrading-ghost-from-3-x-to-5-x/31043/8 "2022-06-29T19:47:10Z")

</div>

Yes I missed that in the documentation and had to start from an old snapshot and was able to bypass this issue. Currently facing migration issues at the last step, but I think that this question has been answered. Thank you!

---

<div class="post-metadata">

**Author:** ![tharris](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@tharris](https://forum.ghost.org/u/tharris)\
**Post date:** [November 19, 2022, 7:05am UTC](https://forum.ghost.org/t/migration-error-upgrading-ghost-from-3-x-to-5-x/31043/9 "2022-11-19T07:05:46Z")

</div>

I’m having this same issue. Did you ever get a resolution? My MySql was on v8 before I started the upgrade.

---

<div class="post-metadata">

**Author:** ![mjw](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/mjw/32/30781_2.png) [@mjw](https://forum.ghost.org/u/mjw)\
**Post date:** [November 19, 2022, 9:16am UTC](https://forum.ghost.org/t/migration-error-upgrading-ghost-from-3-x-to-5-x/31043/10 "2022-11-19T09:16:01Z")

</div>

@tharris, please start a new thread in #help:self-hosting, and explain the problem and your hosting environment.

---

<div class="post-metadata">

**Author:** ![Johny\_K](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/johny_k/32/10775_2.png) [@Johny\_K](https://forum.ghost.org/u/Johny_K)\
**Post date:** [November 21, 2022, 7:46am UTC](https://forum.ghost.org/t/migration-error-upgrading-ghost-from-3-x-to-5-x/31043/11 "2022-11-21T07:46:35Z")

</div>

I had similar issues in the past related to incomplete migration.  
In my case they were related to the DB.

I was able to solve them by forcing installation of older version:

### Force update

If an update fails you can start by forcing a retry to attempt the upgrade a second time.

`ghost update --force`

### Rollback

If something goes wrong, you can always revert to the previous stable version of Ghost.

`ghost update --rollback`

There was difference in the table structure which was solved after:

- ghost 3 → ghost 3 max
- ghost 4 → ghost 4 max
- ghost 5
