How to connect or change a domain for your Ghost CMS website on a Hostinger VPS

5 min read time

How to connect or change a domain for your Ghost CMS website on a Hostinger VPS

This guide covers the full process of connecting or changing a domain for a ghost cms website on a hostinger vps end-to-end, including the common snags that come up along the way and how to fix them.

Part 1: Point Your Domain to the VPS

  1. In hPanel → Domains → your domain → DNS/Nameservers, add an A record:
    • Name: @ (root domain)
    • Points to: your VPS's public IP (find it in hPanel → VPS → Overview)
  2. Optionally add a second A record for www pointing to the same IP.
  3. DNS changes can take anywhere from a few minutes to a few hours to propagate. Check status at dnschecker.org.

Part 2: Access Your VPS

You can use either:

  • SSH from your own terminal: ssh root@your-vps-ip
  • Browser-based terminal: hPanel → VPS → your VPS → look for "Browser Terminal" / "Console" (useful if SSH keeps failing/locking you out)

Common SSH issues:

  • "Permission denied" repeatedly → you may be temporarily rate-limited (fail2ban). Wait 10–15 minutes, or reset the root password in hPanel → VPS → Settings.
  • Terminal shows nothing while typing the password — that's normal masking behavior, not a bug.

Part 3: Find Your Ghost Installation

If you don't already know the path, search for it:

find / -maxdepth 6 -iname "config.production.json" 2>/dev/null

This returns something like:

/home/user/htdocs/yourdomain.tld/config.production.json

The folder containing that file is your Ghost install directory.

Check who owns it:

ls -ld /home/user/htdocs/yourdomain.tld

If it's owned by a non-root user (commonly user), switch to that account to run Ghost-CLI commands:

sudo -iu user

(Note: plain su - user may be blocked on some Hostinger VPS setups — use sudo -iu user instead.)


Part 4: Update the Ghost Site URL

From inside the Ghost install directory:

cd /home/user/htdocs/yourdomain.tld
ghost config url https://yourdomain.tld

This sets just the URL key directly (faster than the full interactive ghost config wizard, which may not prompt if other values are already valid).


Part 5: Set Up Nginx for the New Domain

ghost setup nginx

Common issue — sudo permission error:

Sorry, user user is not allowed to execute '/usr/bin/mv ...' as root

Fix: add your user to the sudo group (run as root):

usermod -aG sudo user

Then log out and back in (sudo -iu user again) so the group change takes effect, and retry ghost setup nginx.


Part 6: Set Up SSL

Try Ghost-CLI's built-in method first:

ghost setup ssl

Common issue — "Nginx config file does not exist, skipping SSL setup" even though the file is actually there. This happens when your non-root user can't directly read /etc/nginx/sites-available/ (a permissions quirk on some Hostinger VPS images), which breaks Ghost-CLI's own file-existence check.

Workaround — use Certbot directly instead:

# check if certbot is installed
which certbot

# if not installed (run as root):
sudo apt update
sudo apt install certbot python3-certbot-nginx -y

# issue and auto-configure the certificate:
sudo certbot --nginx -d yourdomain.tld

Certbot will ask for an email (renewal notices) and terms agreement, then automatically edit your Nginx config and reload it.


Part 7: Start/Restart Ghost (and Fix Systemd Issues)

ghost restart

If Ghost was never running under systemd correctly (common after a manual reinstall or fresh domain change), you may hit a chain of errors. Here's the fix sequence, in order:

7a. "Systemd process manager has not been set up or is corrupted"

ghost setup linux-user systemd

7b. "The 'ghost' user has not been created" (even after running the above)

Check if the user actually exists:

id ghost

If not, create it manually:

useradd --system --no-create-home --shell /usr/sbin/nologin ghost

7c. Systemd setup still skips with the same "ghost user not created" message

This is because Ghost-CLI's check doesn't just look for the existence of the ghost user — it checks whether the ghost user owns your Ghost install's content folder. Fix ownership:

chown -R ghost:ghost /home/user/htdocs/yourdomain.tld
usermod -aG ghost user

Then retry:

ghost setup systemd

7d. "Checking file permissions" errors listing specific files

sudo find ./ ! -path "./versions/*" ! -path "./.pnpm-store/*" -type f -exec chmod 664 {} \;
sudo find ./ -type d -exec chmod 00775 {} \;

7e. Service starts but fails immediately — check the real error

Ghost-CLI's own error messages are often too generic. Get the actual system-level error:

sudo journalctl -u ghost_yourservicename -n 50

If you see "Changing to the requested working directory failed: Permission denied": The ghost system user can't traverse the folder path down to your site (or down to the Node binary, if Node was installed via nvm under a personal user account like /home/user/.nvm/...). Fix by granting read/execute (traverse) permission on every folder in the path:

chmod o+rx /home/user
chmod o+rx /home/user/htdocs
chmod -R o+rx /home/user/.nvm

You can check exactly which folder in a path is blocking access with:

namei -l /path/to/the/file

This prints every folder in the chain with its permissions, so you can spot the culprit.

7f. Confirm it's running

systemctl status ghost_yourservicename

Look for "Active: active (running)" in the output.


Part 8: Configure Transactional Email (SMTP)

Ghost has two separate mail systems:

  • Newsletter/bulk email — configured in the admin dashboard (Settings → Email newsletter), typically via Mailgun.
  • Transactional email (staff invites, password resets) — configured only in config.production.json, not the dashboard.

Set transactional email via Ghost-CLI (example using Brevo):

ghost config mail.transport SMTP
ghost config mail.options.host smtp-relay.brevo.com
ghost config mail.options.port 587
ghost config mail.options.secure false
ghost config mail.options.auth.user "your-smtp-login@smtp-brevo.com"
ghost config mail.options.auth.pass "your-actual-smtp-key"
ghost restart

Critical gotcha: Port 587 requires secure: false (STARTTLS). Port 465 requires secure: true. Mismatching these causes TLS handshake errors.

Another gotcha: Setting secure via ghost config from the CLI can save it as the string "false" instead of the boolean false. In JavaScript, the string "false" is truthy — meaning Ghost still treats it as secure: true. If you hit a TLS version error after setting this, open the config file directly and fix it:

nano config.production.json

Make sure it reads:

"secure": false,

(no quotes around false), then ghost restart.

If you get "Unauthorized IP address" from your SMTP provider: Most providers (Brevo included) require you to authorize your VPS's sending IP address in their dashboard before SMTP relaying works. Check your provider's account settings for an "Authorized IPs" or "Senders" section, and also check your email inbox for an auto-sent confirmation link.


Quick Reference: Common Error → Fix

Error Fix
SSL_ERROR_UNRECOGNIZED_NAME_ALERT in browser No valid SSL cert issued yet for that domain — see Part 6
502 Bad Gateway Nginx/SSL is fine, but Ghost itself isn't running — see Part 7
Permission denied on SSH Wrong password / rate-limited — reset password in hPanel, wait, or use browser terminal
not allowed to execute ... as root User not in sudo group — usermod -aG sudo user
"ghost" user has not been created Create user manually + fix folder ownership — see Part 7b/7c
Changing to the requested working directory failed: Permission denied (in journalctl) Missing traverse (o+rx) permission somewhere in the folder path — see Part 7e
ECONNREFUSED ::1:587 sending email Mail transport not configured — see Part 8
wrong version number (TLS) sending email secure set incorrectly for the port, or stored as a string — see Part 8
Unauthorized IP address sending email Authorize your VPS IP in your SMTP provider's dashboard