Do you think Node 20 could be the issue?
I did it from https://deb.nodesource.com/setup_18.x
, not nvm
I can install Node 18 and try again.
Do you think Node 20 could be the issue?
I did it from https://deb.nodesource.com/setup_18.x
, not nvm
I can install Node 18 and try again.
Itâs worth a try âŚ
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash
sudo apt install nodejs --yes
sudo npm install ghost-cli@latest -g
So I got Node 18 and when tried to start there seems to be some kind of error connecting to the database, so that is something different:
May 15 20:52:13 blog node[2393]: [2024-05-15 20:52:13] INFO Ctrl+C to shut down
May 15 20:52:13 blog node[2393]: [2024-05-15 20:52:13] INFO Ghost server started in 1.326s
May 15 20:52:13 blog node[2393]: [2024-05-15 20:52:13] INFO Bootstrap client was closed.
May 15 20:52:13 blog node[2393]: [2024-05-15 20:52:13] ERROR connect ECONNREFUSED ::1:3306
May 15 20:52:13 blog node[2393]:
May 15 20:52:13 blog node[2393]: connect ECONNREFUSED ::1:3306
May 15 20:52:13 blog node[2393]: "Unknown database error"
May 15 20:52:13 blog node[2393]: Error ID:
May 15 20:52:13 blog node[2393]: 500
May 15 20:52:13 blog node[2393]: Error Code:
May 15 20:52:13 blog node[2393]: ECONNREFUSED
May 15 20:52:13 blog node[2393]: ----------------------------------------
May 15 20:52:13 blog node[2393]: Error: connect ECONNREFUSED ::1:3306
May 15 20:52:13 blog node[2393]: at /var/www/ghost/versions/5.82.9/node_modules/knex-migrator/lib/database.js:57:19
May 15 20:52:13 blog node[2393]: at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)
May 15 20:52:13 blog node[2393]:
May 15 20:52:13 blog node[2393]: [2024-05-15 20:52:13] WARN Ghost is shutting down
May 15 20:52:13 blog node[2393]: [2024-05-15 20:52:13] WARN Ghost has shut down
May 15 20:52:13 blog node[2393]: [2024-05-15 20:52:13] WARN Your site is now offline
May 15 20:52:13 blog node[2393]: [2024-05-15 20:52:13] WARN Ghost was running for a few seconds
May 15 20:52:13 blog node[2393]: [2024-05-15 20:52:13] INFO Bootstrap client was closed.
May 15 20:52:13 blog systemd[1]: Stopping Ghost systemd service for blog: jvlobo-com...
May 15 20:52:14 blog node[2368]: /usr/lib/node_modules/ghost-cli/lib/process-manager.js:46
May 15 20:52:14 blog node[2368]: throw error;
May 15 20:52:14 blog node[2368]: ^
May 15 20:52:14 blog node[2368]: {
May 15 20:52:14 blog node[2368]: message: {
May 15 20:52:14 blog node[2368]: statusCode: 500,
May 15 20:52:14 blog node[2368]: errorType: 'DatabaseError',
May 15 20:52:14 blog node[2368]: level: 'critical',
May 15 20:52:14 blog node[2368]: id: 500,
May 15 20:52:14 blog node[2368]: help: 'Unknown database error',
May 15 20:52:14 blog node[2368]: code: 'ECONNREFUSED',
May 15 20:52:14 blog node[2368]: property: null,
May 15 20:52:14 blog node[2368]: redirect: null,
May 15 20:52:14 blog node[2368]: hideStack: false,
May 15 20:52:14 blog node[2368]: message: 'connect ECONNREFUSED ::1:3306',
May 15 20:52:14 blog node[2368]: name: 'DatabaseError',
May 15 20:52:14 blog node[2368]: errno: -111,
May 15 20:52:14 blog node[2368]: syscall: 'connect',
May 15 20:52:14 blog node[2368]: address: '::1',
May 15 20:52:14 blog node[2368]: port: 3306,
May 15 20:52:14 blog node[2368]: fatal: true
May 15 20:52:14 blog node[2368]: }
May 15 20:52:14 blog node[2368]: }
May 15 20:52:14 blog node[2368]: Node.js v18.20.2
May 15 20:52:14 blog systemd[1]: ghost_jvlobo-com.service: Main process exited, code=exited, status=1/FAILURE
May 15 20:52:14 blog systemd[1]: ghost_jvlobo-com.service: Failed with result 'exit-code'.
May 15 20:52:14 blog systemd[1]: Stopped Ghost systemd service for blog: jvlobo-com.
Iâll try to figure out what is happening now, MySQL is running:
Ok, I just saw this post and I changed from localhost
to 127.0.0.1
on my config file and now it doesnât throw that error anymore.
It starts with no errors, but if I try to get to my site I see:
If I restart sometimes I see the error:
502 Bad Gateway
---
nginx/1.18.0 (Ubuntu)
If I check the journal command I donât see much, still the theme issue and this:
It doesnât tell me much
Itâs late here, so Iâll be brief. MySQL 8 uses sockets for authentication, so you need to change this to password for root
and possibly the Ghost user or the database user specified in production.config.json
.
Something like this.
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<password>';
QUIT;
Youâre almost there!
Thanks.
That is done:
Restarted Ghost but still the same. I donât se anything new on the journal either.
Any ideas?
Thank you!
From the installation directory, try ghost run
. Does the site load? Youâll also get output on the terminal.
Edit: Also, try ghost log --error
.
ghost run
seems to work fine (only throwing the theme
warning)
However, if I run ghost log --error
I get a database connection error over and over:
lobo@blog:/var/www/ghost$ ghost log --error
Love open source? Weâre hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org
+ sudo systemctl is-active ghost_jvlobo-com
[2024-05-16 10:57:09] ERROR
NAME: DatabaseError
CODE: ECONNREFUSED
MESSAGE: connect ECONNREFUSED 127.0.0.1:3306
level: critical
"Unknown database error"
Error: connect ECONNREFUSED 127.0.0.1:3306
at /var/www/ghost/versions/5.82.9/node_modules/knex-migrator/lib/database.js:57:19
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)
[2024-05-16 10:57:12] ERROR
NAME: DatabaseError
CODE: ECONNREFUSED
MESSAGE: connect ECONNREFUSED 127.0.0.1:3306
level: critical
"Unknown database error"
Error: connect ECONNREFUSED 127.0.0.1:3306
at /var/www/ghost/versions/5.82.9/node_modules/knex-migrator/lib/database.js:57:19
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)
[2024-05-16 10:57:16] ERROR
NAME: DatabaseError
CODE: ECONNREFUSED
MESSAGE: connect ECONNREFUSED 127.0.0.1:3306
level: critical
"Unknown database error"
Database seems to be running in the 3306
port and if I try to connect with the ghost database user and the password indicated in the Ghost config file I can access with no issues.
Iâm not sure what is causing the issue while trying to connect to the database.
Please share your production.config.json
file, and post with the <\> button in the forum post editor. Remove passwords, and other personal data, but keep the database user line intact.
This is the production.config.json
{
"url": "https://url.com",
"server": {
"port": 2368,
"host": "127.0.0.1"
},
"database": {
"client": "mysql",
"connection": {
"host": "127.0.0.1",
"user": "ghost-454",
"password": "password",
"database": "ghost_prod"
}
},
"mail": {
"transport": "Direct"
},
"logging": {
"transports": [
"file",
"stdout"
]
},
"process": "systemd",
"paths": {
"contentPath": "/var/www/ghost/content"
}
}
Just an update
I was able to reach my site when starting the server again with ghost run
(not sure what happened the previous time I ran that command but it was not loading).
I have also tried running it again with ghost start
and in that case the site is not reachable (error 502).
But at least I can see it with ghost run
and access the admin panel (and the only error shown on console is the theme situation)
I note that you used root
to connect to the database. Does sudo mysql -u ghost-454 -p
work for you, too?
Yes it does, I only used root
because I was doing the mysql_native_password
.
But I can access with ghost-454
and the password specified on the config file with no problem.
Since I can access the website when starting with ghost run
I enabled the default theme on the admin panel and I donât get any theme errores now. But it still doesnât work with ghost start
.
With ghost run
this is the log I get:
lobo@blog:/var/www/ghost$ ghost run
Love open source? Weâre hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org
The `ghost run` command is used by the configured Ghost process manager and for debugging. If you're not running this to debug something, you should run `ghost start` instead.
+ sudo node current/index.js
[2024-05-16 13:21:00] INFO Ghost is running in production...
[2024-05-16 13:21:00] INFO Your site is now available on https://jvlobo.com/
[2024-05-16 13:21:00] INFO Ctrl+C to shut down
[2024-05-16 13:21:00] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED.
[2024-05-16 13:21:00] WARN Tries: 0
[2024-05-16 13:21:00] WARN Retrying...
[2024-05-16 13:21:00] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED.
[2024-05-16 13:21:00] WARN Tries: 1
[2024-05-16 13:21:00] WARN Retrying...
[2024-05-16 13:21:00] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED.
[2024-05-16 13:21:00] WARN Tries: 2
[2024-05-16 13:21:00] WARN Retrying...
[2024-05-16 13:21:00] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED.
[2024-05-16 13:21:00] INFO Ghost server started in 2.159s
[2024-05-16 13:21:00] INFO Database is in a ready state.
[2024-05-16 13:21:00] INFO Ghost database ready in 2.474s
[2024-05-16 13:21:01] WARN Missing mail.from config, falling back to a generated email address. Please update your config file and set a valid from address
[2024-05-16 13:21:05] INFO Adding offloaded job to the queue
[2024-05-16 13:21:05] INFO Scheduling job mentions-email-report at 26 18 * * * *. Next run on: Thu May 16 2024 14:18:26 GMT+0000 (Coordinated Universal Time)
[2024-05-16 13:21:06] INFO Adding offloaded job to the queue
[2024-05-16 13:21:06] INFO Scheduling job clean-expired-comped at 18 13 4 * * *. Next run on: Fri May 17 2024 04:13:18 GMT+0000 (Coordinated Universal Time)
[2024-05-16 13:21:06] INFO Adding offloaded job to the queue
[2024-05-16 13:21:06] INFO Scheduling job clean-tokens at 6 12 19 * * *. Next run on: Thu May 16 2024 19:12:06 GMT+0000 (Coordinated Universal Time)
[2024-05-16 13:21:06] INFO Ghost URL Service Ready in 8.099s
[2024-05-16 13:21:06] INFO Ghost booted in 8.111s
[2024-05-16 13:21:06] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED.
[2024-05-16 13:21:06] WARN Tries: 0
[2024-05-16 13:21:06] WARN Retrying...
[2024-05-16 13:21:06] INFO Adding offloaded job to the queue
[2024-05-16 13:21:06] INFO Scheduling job update-check at 1 35 5 * * *. Next run on: Fri May 17 2024 05:35:01 GMT+0000 (Coordinated Universal Time)
[2024-05-16 13:21:06] INFO Running milestone emails job on Sun May 19 2024 13:21:06 GMT+0000 (Coordinated Universal Time)
[2024-05-16 13:21:06] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED.
[2024-05-16 13:21:06] WARN Tries: 1
[2024-05-16 13:21:06] WARN Retrying...
[2024-05-16 13:21:06] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED.
[2024-05-16 13:21:06] WARN Tries: 2
[2024-05-16 13:21:06] WARN Retrying...
[2024-05-16 13:21:06] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED.
[2024-05-16 13:21:15] WARN {{#get}} helper took 273ms to complete
{{#get}} helper took 273ms to complete
Error ID:
2c174550-1387-11ef-8884-b98844fd4511
Error Code:
SLOW_GET_HELPER
Details:
api: postsPublic.browse
apiOptions:
limit: 12
include: authors
context:
member: null
returnedRows: 12
[2024-05-16 13:21:15] INFO "GET /" 200 959ms
[2024-05-16 13:21:15] INFO "GET /assets/built/screen.css?v=d7853e827b" 200 19ms
[2024-05-16 13:21:15] INFO "GET /assets/built/source.js?v=d7853e827b" 200 22ms
[2024-05-16 13:21:15] INFO "GET /public/cards.min.js?v=d7853e827b" 200 23ms
[2024-05-16 13:21:15] INFO "GET /public/cards.min.css?v=d7853e827b" 200 23ms
And I can access the websiteâŚ
I have no idea why it doesnât work with ghost start
.
Any ideas?
Thank you!
Please enter this: ls /usr/lib/systemd/system/ghost*
. This should provide the name of the Ghost service. Then, systemctl status <service-name>
.
Earlier, I noticed that you had two users. I think this is part of the problem.
Run this, share the output.
id -u ghost
stat /var/www/ghost/content
This is the output:
lobo@blog:/var/www/ghost$ id -u ghost
999
lobo@blog:/var/www/ghost$ stat /var/www/ghost/content
File: /var/www/ghost/content
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: fc01h/64513d Inode: 512015 Links: 11
Access: (0775/drwxrwxr-x) Uid: ( 999/ ghost) Gid: ( 999/ ghost)
Access: 2024-05-15 20:30:24.911873358 +0000
Modify: 2024-05-15 18:01:29.888463312 +0000
Change: 2024-05-16 13:29:29.459272631 +0000
Birth: -
That looks okay, but letâs do this, too.
sudo chown -R ghost:ghost /var/www/ghost/content
ghost setup systemd
Done:
lobo@blog:/var/www/ghost$ sudo chown -R ghost:ghost /var/www/ghost/content
[sudo] password for lobo:
lobo@blog:/var/www/ghost$ ghost setup systemd
Love open source? Weâre hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org
Systemd service has already been set up. Skipping Systemd setup
âš Setting up Systemd [skipped]
No news tho, still not working with ghost start
How about creating the systemd
file?
[Unit]
Description=Ghost systemd service for blog: jvlobo-com
Documentation=https://ghost.org/docs/
[Service]
Type=simple
WorkingDirectory=/var/www/ghost
User=999
Environment="NODE_ENV=production"
ExecStart=/usr/bin/node /usr/bin/ghost run
Restart=always
[Install]
WantedBy=multi-user.target
Place this in /usr/lib/systemd/system/
and save as ghost_jvlobo-com.service
.
Now try sudo systemctl enable ghost_jvlobo-com.service
and then sudo systemctl status ghost_jvlobo-com.service
.