If @Matifou's answer here doesn't work, do the following instead:
The fix for anyone: run jekyll serve
on an unused port:
Two ways:
- In your
_config.yml
file, specify a port other than 4000
like this, for example:
port: 4001
- OR (my preferred choice), add
--port 4001
to your jekyll serve
command, like this, for example:
bundle exec jekyll serve --livereload --port 4001
From: https://jekyllrb.com/docs/configuration/options/#serve-command-options
See my answer here: Is it possible to serve multiple Jekyll sites locally?
My particular problem: NoMachine is interfering:
When I run:
bundle exec jekyll serve --livereload --drafts --unpublished
I get these errors:
jekyll 3.9.0 | Error: Address already in use - bind(2) for 127.0.0.1:4000
.
.
.
/usr/lib/ruby/2.7.0/socket.rb:201:in `bind': Address already in use - bind(2) for 127.0.0.1:4000 (Errno::EADDRINUSE)
ps aux | grep jekyll
doesn't show any processes running except this grep
command itself. So, that doesn't help.
sudo lsof -wni tcp:4000
, however, shows a running nxd
nx daemon process:
$ sudo lsof -wni tcp:4000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nxd 914803 nx 3u IPv4 7606783 0t0 TCP *:4000 (LISTEN)
nxd 914803 nx 4u IPv6 7599664 0t0 TCP *:4000 (LISTEN)
I discovered this is due to my NoMachine remote login server.
If running NoMachine, click on the NoMachine icon in the top-right of your task bar. Ex: this is on Ubuntu 20.04:
Then click on "Show server status" --> Ports, and you'll see that NoMachine is running nx
on Port 4000, which is interfering:
So, use the fix above to serve jekyll on a different port, such as 4001
instead of 4000
. I recommend leaving the NoMachine port settings as-is, on port 4000
, because NoMachine says:
- Automatic updates require that hosts with NoMachine client or server installed have access to the NoMachine update server on port
4000
and use the TCP protocol.
See also:
- Is it possible to serve multiple Jekyll sites locally?
- my answer