Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED #1017

Closed
cooervo opened this issue Oct 7, 2019 · 16 comments
Closed

Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED #1017

cooervo opened this issue Oct 7, 2019 · 16 comments

Comments

@cooervo
Copy link

cooervo commented Oct 7, 2019

Hi ghost team,

I have tried to debug this issue since September 26, 2019. Sadly I haven't had much progress. This my own Digital Ocean Server, with Ubuntu and Ghost which has worked without problems since approximately 6months ago (July 2019), until very recently, One day I just logged in and ran ghost stop and then ghost start and after that it hasn't worked again.

Steps to reproduce

  1. ssh root@mywebsite.com
  2. sudo -i -u ghost-mgr
  3. cd /var/www/ghost
  4. ghost runoutput:
[2019-10-07 16:30:07] INFO Ghost is running in production...
[2019-10-07 16:30:07] INFO Your site is now available on https://www.mywebsite.com/
[2019-10-07 16:30:07] INFO Ctrl+C to shut down
[2019-10-07 16:30:07] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-10-07 16:30:07] WARN Tries: 0
[2019-10-07 16:30:07] WARN Retrying...
[2019-10-07 16:30:08] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-10-07 16:30:08] WARN Tries: 1
[2019-10-07 16:30:08] WARN Retrying...
[2019-10-07 16:30:08] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-10-07 16:30:08] WARN Tries: 2
[2019-10-07 16:30:08] WARN Retrying...
[2019-10-07 16:30:08] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-10-07 16:30:08] INFO Ghost boot 3.267s

Permissions of /var/www/ghost/ dir after running ls -la`:

total 48
drwxrwxr-x 8 ghost-mgr ghost     4096 Oct  6 07:34 .
drwxrwxr-x 4 root      root      4096 May 14 20:15 ..
-rw-rw-r-- 1 ghost-mgr ghost      124 Oct  6 07:34 .ghost-cli
drwxrwxr-x 8 ghost-mgr ghost     4096 Jul  7 09:34 .git
-rw-rw-r-- 1 ghost-mgr ghost       83 Jun  9 10:57 .gitignore
-rw-rw-r-- 1 ghost-mgr ghost      562 Oct  3 14:10 config.production.json
drwxrwxr-x 8 ghost     ghost     4096 Jun  2 14:39 content
lrwxrwxrwx 1 ghost-mgr ghost-mgr   30 Oct  6 07:34 current -> /var/www/ghost/versions/2.31.1
drwxr-xr-x 2 ghost-mgr ghost-mgr 4096 Sep 27 10:08 locales
drwxrwxr-x 2 ghost-mgr ghost     4096 Jun  9 10:57 node_modules
-rw-rw-r-- 1 ghost-mgr ghost       27 Jun  9 10:57 package-lock.json
drwxrwxr-x 4 ghost-mgr ghost     4096 Jun 20 10:21 system
drwxrwxr-x 4 ghost-mgr ghost     4096 Oct  6 07:34 versions

Are the permissions okay?

Contents of my config.production.json:

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

Is the config file okay?

Log file

cat ~/var/www/ghost/content/logs/https___www_mywebsite_com_production.log] contents:

{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":30,"msg":"Ghost is running in production...","time":"2019-10-07T16:26:24.644Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":30,"msg":"Your site is now available on https://www.mifitnessfacil.com/","time":"2019-10-07T16:26:24.646Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":30,"msg":"Ctrl+C to shut down","time":"2019-10-07T16:26:24.647Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":40,"msg":"Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED","time":"2019-10-07T16:26:24.651Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":40,"msg":"Tries: 0","time":"2019-10-07T16:26:24.652Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":40,"msg":"Retrying...","time":"2019-10-07T16:26:24.653Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":40,"msg":"Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED","time":"2019-10-07T16:26:24.804Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":40,"msg":"Tries: 1","time":"2019-10-07T16:26:24.805Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":40,"msg":"Retrying...","time":"2019-10-07T16:26:24.805Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":40,"msg":"Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED","time":"2019-10-07T16:26:24.957Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":40,"msg":"Tries: 2","time":"2019-10-07T16:26:24.958Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":40,"msg":"Retrying...","time":"2019-10-07T16:26:24.958Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":40,"msg":"Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED","time":"2019-10-07T16:26:25.109Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":30,"msg":"Ghost boot 4.248s","time":"2019-10-07T16:26:25.110Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":6851,"level":40,"msg":"Ghost has shut down","time":"2019-10-07T16:28:49.490Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":30,"msg":"Ghost is running in production...","time":"2019-10-07T16:30:07.975Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":30,"msg":"Your site is now available on https://www.mifitnessfacil.com/","time":"2019-10-07T16:30:07.978Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":30,"msg":"Ctrl+C to shut down","time":"2019-10-07T16:30:07.979Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":40,"msg":"Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED","time":"2019-10-07T16:30:07.984Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":40,"msg":"Tries: 0","time":"2019-10-07T16:30:07.984Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":40,"msg":"Retrying...","time":"2019-10-07T16:30:07.985Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":40,"msg":"Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED","time":"2019-10-07T16:30:08.136Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":40,"msg":"Tries: 1","time":"2019-10-07T16:30:08.137Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":40,"msg":"Retrying...","time":"2019-10-07T16:30:08.137Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":40,"msg":"Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED","time":"2019-10-07T16:30:08.288Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":40,"msg":"Tries: 2","time":"2019-10-07T16:30:08.288Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":40,"msg":"Retrying...","time":"2019-10-07T16:30:08.288Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":40,"msg":"Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED","time":"2019-10-07T16:30:08.440Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":30,"msg":"Ghost boot 3.267s","time":"2019-10-07T16:30:08.441Z","v":0}
{"name":"Log","hostname":"fitness-ghost-droplet","pid":7024,"level":40,"msg":"Ghost has shut down","time":"2019-10-07T16:33:13.435Z","v":0}

Technical details

  • OS: Ubuntu 18.04.3 LTS (bionic)
  • Node Version: 10.16.3
  • Ghost-CLI version: 1.11.0
  • Ghost version: 2.31.1
  • Environment: Production

Bug submission checklist

Please fill out this checklist to acknowledge that you followed the requirements to submit a bug report.

  • [ x ] Tried to find help in the forum & docs
  • [ x ] Checked for existing issues
  • [ x ] Attached log file
  • [ x ] Provided technical details incl. operating system
@acburdine
Copy link
Member

@cooervo this might be related to #805, but would you be able to try removing the bootstrap-socket section from your config.production.json and re-starting?

The error that's occurring is that either Ghost, or the CLI can't connect to the bootstrap socket on port 8000, so either the config.production.json is messing with things or there's a permissions issue preventing Ghost/Ghost-CLI from connecting to port 8000.

@cooervo
Copy link
Author

cooervo commented Oct 7, 2019

@acburdine Thanks removing bootstrap-socket from the config.production.json solved that issue yet blog still doesn't work correctly I still get 502 Bad Gateway nginx/1.14.0 (Ubuntu).

ghost run #output:

+ sudo node current/index.js
[2019-10-07 17:15:14] INFO Ghost is running in production...
[2019-10-07 17:15:14] INFO Your site is now available on https://www.mifitnessfacil.com/
[2019-10-07 17:15:14] INFO Ctrl+C to shut down
[2019-10-07 17:15:14] INFO Ghost boot 2.429s

ghost doctor

✔ Checking system Node.js version
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking operating system compatibility
✔ Checking for a MySQL installation
+ sudo systemctl is-active ghost_mifitnessfacil-com
Instance is currently running
ℹ Validating config [skipped]
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability

@acburdine
Copy link
Member

based on your config.production.json, it appears your blog is running on port 2369 - is that the same port that your nginx configuration is pointing to?

@cooervo
Copy link
Author

cooervo commented Oct 7, 2019

@acburdine this is what nginx.conf looks like:

cat /etc/nginx/nginx.conf

Output:


user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
	worker_connections 768;
	# multi_accept on;
}

http {

	##
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	# server_tokens off;

	# server_names_hash_bucket_size 64;
	# server_name_in_redirect off;

	include /etc/nginx/mime.types;
	default_type application/octet-stream;

	##
	# SSL Settings
	##

	ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
	ssl_prefer_server_ciphers on;

	##
	# Logging Settings
	##

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	##
	# Gzip Settings
	##

	gzip on;

	# gzip_vary on;
	# gzip_proxied any;
	# gzip_comp_level 6;
	# gzip_buffers 16 8k;
	# gzip_http_version 1.1;
	# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

	##
	# Virtual Host Configs
	##

	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
}


#mail {
#	# See sample authentication script at:
#	# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#	# auth_http localhost/auth.php;
#	# pop3_capabilities "TOP" "USER";
#	# imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#	server {
#		listen     localhost:110;
#		protocol   pop3;
#		proxy      on;
#	}
#
#	server {
#		listen     localhost:143;
#		protocol   imap;
#		proxy      on;
#	}
#}

@acburdine
Copy link
Member

the nginx configuration i'm interested in should be /etc/nginx/sites-enabled/<your site name>.conf

@cooervo
Copy link
Author

cooervo commented Oct 7, 2019

@acburdine there are 4 files: 1 for ssl with www. the other without www. and the same without ssl.

ls
mifitnessfacil.com-ssl.conf  www.mifitnessfacil.com-ssl.conf
mifitnessfacil.com.conf      www.mifitnessfacil.com.conf

Since the website was working on https I'll paste ssl content let me know if you need the other files content:

cat mifitnessfacil.com-ssl.conf

Output:

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

    server_name mifitnessfacil.com;
    root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)

    ssl_certificate /etc/letsencrypt/mifitnessfacil.com/fullchain.cer;
    ssl_certificate_key /etc/letsencrypt/mifitnessfacil.com/mifitnessfacil.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:2368;

    }

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

    client_max_body_size 50m;
}

cat www.mifitnessfacil.com-ssl.conf

Output:

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

    server_name www.mifitnessfacil.com;
    root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)

    ssl_certificate /etc/letsencrypt/www.mifitnessfacil.com/fullchain.cer;
    ssl_certificate_key /etc/letsencrypt/www.mifitnessfacil.com/www.mifitnessfacil.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:2368;

    }

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

    client_max_body_size 50m;
}

@acburdine
Copy link
Member

acburdine commented Oct 7, 2019

ok, I see what the problem is 😄 not sure why it happened, but it does appear that the port configuration in your production configuration and the one in the nginx configuration got out of sync.

What you'll need to do is update config.production.json -> set the server.port value to 2368 instead of 2369, then restart Ghost. That should hopefully fix the problem.

@cooervo
Copy link
Author

cooervo commented Oct 7, 2019

@acburdine oh man you don't know how relieved I am to finally fix this. :D x 1'000.000

Thanks for your enormous patience and help. You made my day, my week! 😃

@acburdine
Copy link
Member

Glad to help 😄

Going to close this issue as the problem's been resolved. In the future, the forum (https://forum.ghost.org) is probably the best spot for these types of requests, as it will have greater visibility.

@cooervo
Copy link
Author

cooervo commented Oct 7, 2019

yup I tried the forum before as linked in my original post. But thanks anyways !

@acburdine
Copy link
Member

ah whoops - didn't realize the link above was a link to the forum 😅

@cloudnull
Copy link

@cooervo this might be related to #805, but would you be able to try removing the bootstrap-socket section from your config.production.json and re-starting?

The error that's occurring is that either Ghost, or the CLI can't connect to the bootstrap socket on port 8000, so either the config.production.json is messing with things or there's a permissions issue preventing Ghost/Ghost-CLI from connecting to port 8000.

This was the fix for me. I had to remove the following section from the prod config.

  "bootstrap-socket": {
    "port": 8000,
    "host": "localhost"
  },

Once removed it all started working again.

@HamedMP
Copy link

HamedMP commented Jan 14, 2021

ok, I see what the problem is 😄 not sure why it happened, but it does appear that the port configuration in your production configuration and the one in the nginx configuration got out of sync.

What you'll need to do is update config.production.json -> set the server.port value to 2368 instead of 2369, then restart Ghost. That should hopefully fix the problem.

I have the same issue of bootstrap sockets while doing ghost run and intentionally running my website on 2369 because I ham hosting two different websites on the same server. The nginx (both HTTP and SSL) and ghosts configs are both pointing to the correct port. Removing bootstrap-sockets object didn't help either.

@filipencus
Copy link

Any workaround on this? I spent several days and nothing, except upgrading nodejs version, which is not an option for me.

@inspire22
Copy link

In case anyone else gets this, this happened to me when changing the domain name for a ghost site. Since config set was called while the server was running, it seems to have detected the port was in use and changed the port to a new number automatically.

Compiling the confusion of this, there's two "port:" keys in the config file - the one in the 'server' block seems to be the correct one to edit.

@LivioGama
Copy link

LivioGama commented Sep 28, 2024

In my case, it was happening because I had 644 instead of 664 as right on /lib/systemd/system/ghost_blog.service, and maybe because I had a User as a string. Basically passing from:

[Unit]
Description=Ghost systemd service for blog: blog.liviogama-com
After=network.target

[Service]
Type=simple
WorkingDirectory=/var/www/blog
User=ghostmgr // or I tried "root" and "ghost" as well without success
Environment="NODE_ENV=production"

ExecStart="/usr/bin/node /usr/bin/ghost run"
ExecStop="/usr/bin/node /usr/bin/ghost stop"

Restart=always

[Install]
WantedBy=multi-user.target

to:

[Unit]
Description=Ghost systemd service for blog: blog.liviogama-com
Documentation=https://ghost.org/docs/

[Service]
Type=simple
WorkingDirectory=/var/www/blog
User=998
Environment="NODE_ENV=production"
ExecStart=/usr/bin/node /usr/bin/ghost run
Restart=always

[Install]
WantedBy=multi-user.target

and chmod from 644 to 664 made the trick.

Another error I initially made was to install ghost-cli with bun, and having the wrong paths for both /usr/bin/node and /usr/bin/ghost, so do not hesitate to which node and which ghost on the different users !

Hope it will help someone one day, because I spent countless hours on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants