I am new to Jekyll blogging and trying to view blog locally on
http://localhost:4000
but failed.
➜ my-awesome-site > jekyll serve
Notice: for 10x faster LSI support, please install http://rb-gsl.rubyforge.org/
Configuration file: /home/Git/my-awesome-site/_config.yml
Source: /home/Git/my-awesome-site
Destination: /home/Git/my-awesome-site/_site
Generating...
done.
Configuration file: /home/Git/my-awesome-site/_config.yml
jekyll 2.2.0 | Error: Address already in use - bind(2)
I tried
$ lsof -wni tcp:3000
$ lsof -wni tcp:4000
but both of them return nothing.
My Ruby version is:
➜ my-awesome-site > ruby --version
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
What should I do next? I've re-installed jekyll already but the same problem remains.
See the comments in http://jekyllrb.com/docs/usage/, should help you:
If you need to kill the server, you can
kill -9 1234
where "1234" is the PID.If you cannot find the PID, then do,
ps aux | grep jekyll
and kill the instance. Read more.
Steps here fixed it for me. I had to append 'sudo' along with the commands.
$> sudo lsof -wni tcp:4000
It will give you information of process running on tcp port 4000 which also contains PID (Process ID). Now use command below to kill the process.
$> sudo kill -9 PID
Now you can execute jekyll serve
command to start your site
Try to see which process is using that port, kill it and run again or try running jekyll on different port.
If @Matifou's answer here doesn't work, do the following instead:
jekyll serve
on an unused port:Two ways:
_config.yml
file, specify a port other than 4000
like this, for example:
port: 4001
--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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With