What to do when Ghost goes wrong (ie you loose a password, upgrade fails etc). A few tips on some common Ghost Site Adminstration tasks.
Ghost Error: Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
Following upgrade of Ubuntu from 18.04 (LTS) -> 20.04 (LTS) which disables the nodejs repository, I did a new upate to nodejs 12.x (previous recommended version was 10.x:
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash sudo apt-get install -y nodejs --- --- Followed by ghost-cli update and ghost update $ sudo npm install ghost-cli@latest -g $ cd /var/www/ghost $ ghost update $ ghost start
However ghost fails to start.. and I get the error:
Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
The you can see this by running: ghost run
Problems is that node executable changes from: "nodejs" to "node" so systemd script fails:
[Unit] Description=Ghost systemd service for blog: localhost Documentation=https://docs.ghost.org [Service] Type=simple WorkingDirectory=/var/www/ghost User=1001 Environment="NODE_ENV=production" ExecStart=/usr/bin/nodejs /usr/bin/ghost run Restart=always [Install] WantedBy=multi-user.target
- change "ExecStart" line to use /usr/bin/node,
- do "sudo systemctl daemon reload"
- ghost should now start correctly
Ghost V2 to V3 Database Migration Error
The Ghost team has released Ghost V3, so like other I have upgraded some of my ghost servers to V3.
In doing this I came across this error on doing inplace "ghost update" comment:
$ ghost update + sudo systemctl is-active ghost_ghost-BLAH-com ✔ Checking system Node.js version ✔ Ensuring user is not logged in as ghost user ✔ Checking if logged in user is directory owner ✔ Checking current folder permissions ✔ Checking folder permissions ✔ Checking file permissions ✔ Checking content folder ownership ✔ Checking memory availability ✔ Checking for available migrations ✔ Checking for latest Ghost version ✔ Downloading and updating Ghost to v3.0.0 Checking theme compatibility for Ghost 3.0.0 ✔ Your theme is compatible. You can also check theme compatibility at https://gscan.ghost.org ? Are you sure you want to proceed with migrating to Ghost 3.0.0? Yes ✔ Updating to a major version + sudo systemctl is-active ghost_ghost-BLAH-com + sudo systemctl stop ghost_ghost-BLAH-com ✔ Stopping Ghost ✔ Linking latest Ghost and recording versions + sudo systemctl is-active ghost_ghost-BLAH-com ☱ Stopping Ghost✔ Ensuring user is not logged in as ghost user ✔ Checking if logged in user is directory owner ☲ Restarting Ghost✔ Checking current folder permissions + sudo systemctl is-active ghost_ghost-BLAH-com ✔ Validating config ✔ Checking folder permissions ✔ Checking file permissions ✔ Checking content folder ownership + sudo systemctl start ghost_ghost-BLAH-com ☲ Restarting Ghost+ sudo systemctl stop ghost_ghost-BLAH-com ✖ Restarting Ghost A GhostError occurred. Message: drop table if exists `members_stripe_customers_subscriptions` - ER_TABLEACCESS_DENIED_ERROR: DROP command denied to user 'GHOST_USER'@'GHOST_SERVER.com' for table 'members_stripe_customers_subscriptions' Suggestion: journalctl -u ghost_ghost-BLAH-com -n 50 Debug Information: OS: Ubuntu, v19.04 Node Version: v10.17.0 Ghost-CLI Version: 1.12.0 Environment: production Command: 'ghost update' Additional log info available in: /home/ME/.ghost/logs/ghost-cli-debug-2019-10-26T03_10_33_463Z.log Try running ghost doctor to check your system for known issues. You can always refer to https://ghost.org/docs/api/ghost-cli/ for troubleshooting. ? Unable to upgrade Ghost from v2.31.1 to v3.0.0. Would you like to revert back to v2.31.1? Yes + sudo systemctl is-active ghost_ghost-BLAH-com + sudo systemctl reset-failed ghost_ghost-BLAH-com ✔ Checking system Node.js version ✔ Ensuring user is not logged in as ghost user ✔ Checking if logged in user is directory owner ✔ Checking current folder permissions ✔ Checking folder permissions ✔ Checking file permissions ✔ Checking content folder ownership ✔ Checking for available migrations ✔ Checking for latest Ghost version ℹ Downloading and updating Ghost [skipped] + sudo /var/www/ghost/current/node_modules/.bin/knex-migrator-rollback --force --v 2.31.1 --mgpath /var/www/ghost/current ✖ Rolling back database migrations A GhostError occurred. Message: The database migration in Ghost encountered an error. Help: https://ghost.org/faq/upgrade-to-ghost-2-0/#what-to-do-when-an-upgrade-fails Suggestion: ghost update --rollback Debug Information: OS: Ubuntu, v19.04 Node Version: v10.17.0 Ghost-CLI Version: 1.12.0 Environment: production Command: 'ghost update' Additional log info available in: /home/ME/.ghost/logs/ghost-cli-debug-2019-10-26T03_12_26_245Z.log Try running ghost doctor to check your system for known issues. You can always refer to https://ghost.org/docs/api/ghost-cli/ for troubleshooting.
As per prior posting I converted by sqlite3 ghost to MYSQL and in doing this set permission on database as: GRANT create, delete, insert, select, update, alter,references ON <your-db>.* TO GHOST_DB_USER@<ip/subnet>
Error is pretty clear and consistent with fact that I did not grant "drop" permissions, so fix is to add drop permissions to ghost db acount use:
mysql> show grants for 'USER'@'XXX.XXX.XXX.X/255.255.255.X' ; mysql> GRANT DROP ON `GHOST_DB`.* TO 'USER'@'XXX.XXX.XXX.0/255.255.255.X' ; -- or if you have local mysql mysql> show grants for 'USER'@'localhost'; mysql> GRANT DROP ON `GHOST_DB`.* TO 'USER'@'localhost' ; --- and flush mysql> FLUSH PRIVILEGES;
This is likely the most common problem. You have forgotten ghost admin password and password reset mail is not avaiable or working, so you cannot use ghost tools to fix things. The reset requires you to do three things:
|1||Get Database Details||Get the database connection information from ghost by looking at config.production.json (or development) in Ghost root directory (typically /var/www/ghost). Config item is: "database".|
|2||Get DB User Details||Log into your MySQL host (may or may not be the same machine that ghost is on depending on your configuration).|
sudo mysql -u root -p mysql> use <db-name> ; <== (DB from step 1) mysql> select * from users ;
|3||Reset Password||Ghost uses BCrypt Hash for password protection, so simply use known BCryptencrytped password "password" as reset password.|
UPDATE users SET password='$2a$10$BQToDNdBtBKCvnrTmMi5m.NK.7i6Qx7YASs.jTkE86I5zqxzE8klC' WHERE email = '<email-as-per-step-2>' ;
|4||Reset via Ghost||Now just login to Ghost with use id as per Step 2/3 with password "password" (no quotes).|
No use Ghost tools to reset the password.
These instruction also work with sqlite3 database, but rather than going into sql interpreter, you should change directory to <ghost-root>/content/data and then do:
sudo sqlite3 ghost.db
The is no need for the "use <DB>" step with sqlite3.
NOTE: If you have installed an MySQL DB Admin tools then you can do all this quickly and simplely, or just write a script...
Ghost Database Content Migration
Migrating from sqlite (development) to MySQL (production configuration) is documented here.
Reference & Links:
Acknowledgement: Ghost Writer Image from: Sue Tooth - Writing & Editing Services.