Skip to content
Latchkey

Ghost "Invalid config" / config file error in CI

Ghost reads config.<env>.json for its url, database, and mail settings. If that file is missing, malformed, or lacks required keys, Ghost fails at startup with a config validation error before serving anything.

What this error means

Ghost startup fails with "Error: Config file is not valid JSON" or "Error: 'url' is required" / "database is not configured", naming config.production.json.

Ghost
Error: Config file is not valid JSON
  at parse (.../node_modules/bson/...)
  config.production.json
----------------------------------------
"Please check your config file for syntax errors."

Common causes

The config file is malformed JSON

A trailing comma or unquoted key makes config.production.json invalid, and Ghost cannot parse it.

Required keys or the config file are missing

The runner has no config.<env>.json, or it lacks url and database, so Ghost's config validation fails.

How to fix it

Write a valid config from CI values

  1. Generate config.<env>.json with strict JSON (no trailing commas).
  2. Include url, database, and any required keys.
  3. Validate it parses before starting Ghost.
Terminal
cat > config.production.json <<'EOF'
{
  "url": "http://localhost:2368",
  "database": { "client": "mysql", "connection": {
    "host": "127.0.0.1", "user": "root", "password": "root", "database": "ghost"
  } }
}
EOF
node -e "JSON.parse(require('fs').readFileSync('config.production.json'))"

Configure via environment variables

Ghost reads nested config from env vars, avoiding a JSON file entirely.

.github/workflows/ci.yml
env:
  url: http://localhost:2368
  database__client: mysql
  database__connection__host: 127.0.0.1

How to prevent it

  • Generate Ghost config from CI and validate it parses.
  • Keep required keys (url, database) present per environment.
  • Prefer env-var config to avoid JSON syntax mistakes.

Frequently asked questions

What causes "Ghost "Invalid config""?
A trailing comma or unquoted key makes config.production.json invalid, and Ghost cannot parse it.
How do I fix Ghost "Invalid config"?
Write a valid config from CI values

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card