Ghost icon indicating copy to clipboard operation
Ghost copied to clipboard

Invalid database host

Open secondmanveran opened this issue 1 year ago • 3 comments

Issue Summary

Ghost will not connect to new MySQL 8 database server after updating DB host and password.

Steps to Reproduce

  1. Created new MySQL 8 freestanding DB server to facilitate upgrading to v5
  2. Imported tables from MariaDB server.
  3. Updated config.production.json fields db host and db password
  4. Attempted to restart Ghost
  5. Ghost fails with the following error:

Message: Ghost was able to start, but errored during boot with: Invalid database host.

Expectation was that Ghost would restart correctly using new host and password.

Ghost Version

4.32.0, 4.48.2

Node.js Version

16.13.1

How did you install Ghost?

ghost-cli

Database type

MySQL 8

Browser & OS version

No response

Relevant log / error output

✖ Restarting Ghost
A GhostError occurred.

Message: Ghost was able to start, but errored during boot with: Invalid database host.
Help: Please double check your database config.

Debug Information:
    OS: Ubuntu, v20.04.4 LTS
    Node Version: v16.13.1
    Ghost Version: 4.32.0
    Ghost-CLI Version: 1.21.0
    Environment: production
    Command: 'ghost restart'

Code of Conduct

  • [X] I agree to be friendly and polite to people in this repository

secondmanveran avatar Jun 16 '22 13:06 secondmanveran

@secondmanveran This sounds like a configuration issue. What did you have in your database.connection.host config value and can you connect to it using those credentials?

daniellockyer avatar Jul 04 '22 13:07 daniellockyer

Note from our bot: The needs info label has been added to this issue. Updating your original issue with more details is great, but won't notify us, so please make sure you leave a comment so that we can see when you've updated us.

github-actions[bot] avatar Jul 04 '22 13:07 github-actions[bot]

@daniellockyer

I use the internal network IP for my database server.

 "database": {
   "client": "mysql",
   "connection": {
     "host": "192.168.***.***",
     "user": "****",
     "password": "****",
     "database": "ghost_blog"
   }
 },

Same exact setup that was being used for version 4.32, but I had to turn up a new server since the version 5 only accepts MySQL 8, my previous server was MariaDB 10.6.

secondmanveran avatar Jul 08 '22 18:07 secondmanveran

Hey @secondmanveran - very odd. Are you sure your MySQL instance can be connected to from where you're running Ghost? Is there possibly a firewall in action?

daniellockyer avatar Aug 17 '22 05:08 daniellockyer

I'm going to close this as the lack of similar reports means it probably an environment issue, better suited to the forum if @secondmanveran wants to dig in further to what has happened.

ErisDS avatar Aug 31 '22 17:08 ErisDS

Hey @secondmanveran 👋

We've reviewed your bug report and believe the issue is environment specific, rather than a bug. Many questions can be answered by reviewing our documentation. If you can't find an answer then our forum is a great place to get community support, plus it helps create a central location for searching problems/solutions.

github-actions[bot] avatar Aug 31 '22 17:08 github-actions[bot]

I have the same issue on Digital Ocean.

marianstiehler avatar Sep 09 '22 10:09 marianstiehler

@marianstiehler

I have access to the private IP since my ghost server and my db server are in the same network.

Prior to the change to MySQL 8 I could use that private 192.* IP

But for whatever reason Ghost won't recognize this as a valid host anymore. I can use these with other node apps and my Laravel apps, but Ghost blows up.

So I just switched to the public IP and made sure my firewall was open on 3306 and it resolved.

I don't know if this will help you, but it resolved the connection issue.

secondmanveran avatar Sep 09 '22 11:09 secondmanveran

Hey @secondmanveran 👋

We've reviewed your bug report and believe the issue is environment specific, rather than a bug. Many questions can be answered by reviewing our documentation. If you can't find an answer then our forum is a great place to get community support, plus it helps create a central location for searching problems/solutions.

Can you expand on that environment issue ? I'm facing with the same error on synology nas : Have two containers they can ping each other. have no issues with db or password. but still having the same issue.

DennisYildirim avatar Apr 03 '23 13:04 DennisYildirim

@marianstiehler

I have access to the private IP since my ghost server and my db server are in the same network.

Prior to the change to MySQL 8 I could use that private 192.* IP

But for whatever reason Ghost won't recognize this as a valid host anymore. I can use these with other node apps and my Laravel apps, but Ghost blows up.

So I just switched to the public IP and made sure my firewall was open on 3306 and it resolved.

I don't know if this will help you, but it resolved the connection issue.

Hmm in my case, even when i take down the entire firewall it simply wont connect. I believe this is simply a Synology overall settings interfering with this ghost-db relation. Did anyone bother to solve it ? Or the ghost guys simply wont care nas users to make use of this app ?

It works perfectly fine on my PC but wont work on the synology thing somehow.

DennisYildirim avatar Apr 03 '23 13:04 DennisYildirim

Facing the same issue: ERROR Invalid database host. running ghost:5.47.2 in docker container on production. Here's my docker-compose.yml:

version: '3.8'
volumes:
  mysql-volume:
  ghost-volume-en:

services:
      
 ghost:
  image: ghost:5.47.2
  volumes:
    - ghost-volume:/var/lib/ghost/content
    # localized copy of casper theme
    - ./casper:/var/lib/ghost/content/themes/casper
  restart: always
  ports:
    - 2368:2368
  environment:
    url: [REDACTED]
    database__client: mysql
    database__connection__host: mysql
    database__connection__user: bloguser
    database__connection__password: [REDACTED]
    database__connection__database: en_schema
  depends_on:
    - mysql

mysql:  
  image: mysql:8.0
  volumes:
    - mysql-volume:/var/lib/mysql
  environment:
    MYSQL_ROOT_PASSWORD: [REDACTED]
    MYSQL_USER: bloguser
    MYSQL_PASSWORD: [REDACTED]
  entrypoint:
    sh -c "
      echo 'CREATE DATABASE IF NOT EXISTS en_schema; GRANT ALL PRIVILEGES ON en_schema.* TO '\''bloguser'\''; ' > /docker-entrypoint-initdb.d/init.sql;
      echo 'CREATE DATABASE IF NOT EXISTS de_schema; GRANT ALL PRIVILEGES ON de_schema.* TO '\''bloguser'\''; ' >> /docker-entrypoint-initdb.d/init.sql;
      echo 'CREATE DATABASE IF NOT EXISTS fr_schema; GRANT ALL PRIVILEGES ON fr_schema.* TO '\''bloguser'\''; ' >> /docker-entrypoint-initdb.d/init.sql;
      /usr/local/bin/docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password
    "

rubnov avatar May 17 '23 14:05 rubnov

Did you resolve this issue?

mlavelle42 avatar Oct 10 '23 16:10 mlavelle42

Sure.

To be honest I don't remember.

secondmanveran avatar Oct 10 '23 17:10 secondmanveran