1

I've changed from Mac to Linux (Ubuntu) a couple of days ago and I cloned the repo from my team project in GitHub. (It was working before this with Mac). But now, I've got this problem.

I was trying to start the server on local Unix socket (3000) by running

bundle exec puma

but it shows me these errors instead.

[3217] Puma starting in cluster mode...
[3217] * Version 4.3.3 (ruby 2.6.5-p114), codename: Mysterious Traveller
[3217] * Min threads: 1, max threads: 16
[3217] * Environment: development
[3217] * Process workers: 1
[3217] * Preloading application
Traceback (most recent call last):
        13: from /home/shaun/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'
        12: from /home/shaun/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
        11: from /home/shaun/.rvm/gems/ruby-2.6.5/bin/puma:23:in `<main>'
        10: from /home/shaun/.rvm/gems/ruby-2.6.5/bin/puma:23:in `load'
         9: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/bin/puma:10:in `<top (required)>'
         8: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/cli.rb:80:in `run'
         7: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/launcher.rb:172:in `run'
         6: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/cluster.rb:413:in `run'
         5: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/runner.rb:161:in `load_and_bind'
         4: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:90:in `parse'
         3: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:90:in `each'
         2: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:151:in `block in parse'
         1: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:328:in `add_unix_listener'
/home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:328:in `listen': Address already in use - listen(2) (Errno::EADDRINUSE)

I've then tried to run

bundle exec puma -C config/puma.rb -b tcp://127.0.0.1:3001

but the server stops right away without running it.

[3263] Puma starting in cluster mode...
[3263] * Version 4.3.3 (ruby 2.6.5-p114), codename: Mysterious Traveller
[3263] * Min threads: 1, max threads: 16
[3263] * Environment: development
[3263] * Process workers: 1
[3263] * Preloading application
[3263] * Listening on tcp://127.0.0.1:3001
[3263] Use Ctrl-C to stop

I've also tried the methods given in this post: Address already in use - bind(2) (Errno::EADDRINUSE)

Like

lsof -wni tcp:3000

but nothing was shown for me to kill the Pid process.

Can someone please help?

These are the software versions I'm using:

  • Ubuntu 18.04 LTS
  • Ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
  • Puma version 4.3.3

This is the code in config/puma.rb

# vars
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"

# Specifies the `environment` that Puma will run in.
environment ENV.fetch("RACK_ENV") { "production" }

# pidfile and state
pidfile "#{shared_dir}/pids/puma.pid"
state_path "#{shared_dir}/pids/puma.state"

# Threads for serving requests
threads 1, 16

# Workers (cpu cores)
workers ENV.fetch("WEB_CONCURRENCY") { 1 }
preload_app!

# Unix socket to for nginix reverse proxy
bind "unix://#{shared_dir}/sockets/puma.sock"

# Port for local server use
port ENV.fetch("PORT") { 3000 }

# Debugging
debug

# Logging
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true

activate_control_app

rackup "#{app_dir}/config.ru"
Shaun Low
  • 11
  • 3
  • Have you restarted the computer and tried again? If so, how are you defining your listening options in `config/puma.rb`? – anothermh Apr 28 '20 at 08:50
  • @anothermh yes i did restart my computer couple times these few days. Is this the line you're looking for? ```port ENV.fetch("PORT") { 3000 }``` – Shaun Low Apr 28 '20 at 08:55
  • ```app_dir = File.expand_path("../..", __FILE__) shared_dir = "#{app_dir}/shared" environment ENV.fetch("RACK_ENV") { "development" } pidfile "#{shared_dir}/pids/puma.pid" state_path "#{shared_dir}/pids/puma.state" # Threads for serving requests threads 1, 16 workers ENV.fetch("WEB_CONCURRENCY") { 1 } preload_app! bind "unix://#{shared_dir}/sockets/puma.sock" port ENV.fetch("PORT") { 3000 } debug stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true activate_control_app rackup "#{app_dir}/config.ru"``` – Shaun Low Apr 28 '20 at 09:00
  • Don't post code in comments. That's an unreadable mess. Updates to your question go in your question. – anothermh Apr 28 '20 at 17:38
  • @anothermh alright got it. thanks for letting me know. I've updated them in my question above. Really appreciate your help. :) – Shaun Low Apr 29 '20 at 12:18

1 Answers1

0

It looks like you're running another program on port 3000. Run lsof -i:3000 and stop it using kill command when there are some result from the command.

Masafumi Okura
  • 694
  • 3
  • 12