How to upgrade a DigitalOcean marketplace droplet

Turns out the answer was a little more complicated. Although I’m a huge fan of nvm, I decided to go the apt route outlined in a number of articles.

Most of this is captured in Ghost.org’s Supported NodeJS Versions and Compatibility guide, but it skipped a few updates like NPM and ghost-cli, and when I tried to start the service, I received a DB connection refused error. As suggested in this article, it turned out to be a problem with NodeJS v18 preferring IPv6 vs v16 which preferred IPv4. Changing the connection string in config.production.json from localhost to 127.0.0.1 did the trick.

Here’s the complete process that worked for me (I had to restore from snapshot several times to get it right). Power off your droplet and take a snapshot before you begin!!!

# Login as ghost user
sudo -i -u ghost-mgr
cd /var/www/ghost

# Stop ghost
ghost stop

# Change database connection in ghost config from `localhost` to `127.0.0.1`
nano config.production.json

# update yarn key
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

# Download and import the Nodesource GPG key
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg

# Create deb repository
NODE_MAJOR=18 # Use a supported version
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list

# Run update and install NodeJS
sudo apt-get update
sudo apt-get install nodejs -y

# Update NPM to the latest
sudo npm install -g npm@10.2.4

# Update ghost CLI to latest version
sudo npm install -g ghost-cli@latest

# Update ghost with the same version
ghost version
ghost update [version] --force # NOTE: Substitute [version] with your ghost version above

# start the service, test that it works, then stop again. If it fails here, do not proceed

# Update ghost to the latest version
ghost update
2 Likes