Suddenly Unable to Completely Start Ghost After Server Restart

Current state of the blog:

2019-01-27%2023_46_14-502%20Bad%20Gateway

Nginx end of things:

2019/01/28 05:32:54 [error] 772#772: *27 connect() failed (111: Connection refused) while connecting to upstream, client: _IP_ADDRESS_, server: _MY_DOMAIN_.com, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:2369/", host: "_MY_DOMAIN_.com

Ghost end of things (ghost run):

[2019-01-28 05:32:13] INFO Ghost is running in production...
[2019-01-28 05:32:13] INFO Your blog is now available on https://_MY_DOMAIN.com/
[2019-01-28 05:32:13] INFO Ctrl+C to shut down
[2019-01-28 05:32:13] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-01-28 05:32:13] WARN Tries: 0
[2019-01-28 05:32:13] WARN Retrying...
[2019-01-28 05:32:13] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-01-28 05:32:13] WARN Tries: 1
[2019-01-28 05:32:13] WARN Retrying...
[2019-01-28 05:32:13] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-01-28 05:32:13] WARN Tries: 2
[2019-01-28 05:32:13] WARN Retrying...
[2019-01-28 05:32:14] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-01-28 05:32:14] INFO Ghost boot 3.07s

Current configuration(s):.

config.production.json

{
  "url": "https://_MY_DOMAIN.com/",
  "server": {
    "port": 2368,
    "host": "127.0.0.1"
  },
  "database": {
    "client": "mysql",
    "connection": {
      "host": "localhost",
      "user": "ghost",
      "password": "CENSORED",
      "database": "CENSORED"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/www/ghost/content"
  },
  "bootstrap-socket": {
    "port": 8000,
    "host": "localhost"
  }
}

MYDOMAIN-ssl.conf:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name _MY_DOMAIN_.com;
    root /var/www/ghost/system/nginx-root;

    ssl_certificate /etc/letsencrypt/_MY_DOMAIN_.com/fullchain.cer;
    ssl_certificate_key /etc/letsencrypt/_MY_DOMAIN_.com/_MY_DOMAIN_.com.key;
    include /etc/nginx/snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2369;

    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 62m;
}

MYDOMAIN-.conf:

server {
    listen 80;
    listen [::]:80;

    server_name _MY_DOMAIN_.com;
    root /var/www/ghost/system/nginx-root;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2369;

    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 62m;
}

Attempts:

  • I tried killing and searching for all node processes, there were none when ghost wasn’t running.
  • Restarting nginx.
  • No processes appear to be occupying that port.
  • Multiple server restarts.
  • Ghost run, ghost start, ghost restart, ghost stop in every possible order.
  • Updating ghost: Apparently succeeded(?) output:
guser@blog:/var/www/ghost$ ghost upgrade
You are running an outdated version of Ghost-CLI.
It is recommended that you upgrade before continuing.
Run `npm install -g ghost-cli@latest` to upgrade.

+ sudo systemctl is-active ghost_localhost
βœ” 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 v2.12.0
βœ” Linking latest Ghost and recording versions
+ sudo systemctl is-active ghost_localhost
☱ Downloading and updating Ghost to v2.12.0 > Installing dependencies > [5/5] Building fresh packages...βœ” 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_localhost
βœ” Validating config
βœ” Checking folder permissions
βœ” Checking file permissions
βœ” Checking content folder ownership
+ sudo systemctl start ghost_localhost
βœ” Restarting Ghost
β„Ή Removing old Ghost versions [skipped]
guser@blog:/var/www/ghost$ ghost status
+ sudo systemctl is-active ghost_localhost
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Name      β”‚ Location       β”‚ Version β”‚ Status               β”‚ URL                          β”‚ Port β”‚ Process Manager β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ localhost β”‚ /var/www/ghost β”‚ 2.12.0  β”‚ running (production) β”‚ https://_MY_DOMAIN_.com/ β”‚ 2368 β”‚ systemd         β”‚
guser@blog:/var/www/ghost$ npm start --production
npm ERR! path /var/www/ghost/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/var/www/ghost/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/guser/.npm/_logs/2019-01-28T05_53_42_695Z-debug.log

Status still the same.

It looks like nginx is trying to connect to port 2369, but your config has ghost listening on 2368. I’m not sure why that would happen, but you can manually fix it by

either

running ghost config set server.port 2369 and restarting ghost (ghost restart),

or

editing your nginx config to use port 2368 and restarting (sudo nginx -s reload)

1 Like

Not sure how that happened either. Very odd. But that seems to have done the trick! Thank you. I will update if there are any additional issues.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.