Rails server error `initialize ': getaddrinfo: name or service unknown (SocketError)

I am trying to set up a new Rails application and keep getting the following stack trace:

=> Booting Puma
=> Rails 5.1.0.rc1 application starting in development on http://linux-my4o:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.8.2 (ruby 2.4.0-p0), codename: Sassy Salamander
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://linux-my4o:9292
Exiting
/home/chris/.rvm/gems/ruby-2.4.0/gems/puma-3.8.2/lib/puma/binder.rb:269:in `initialize': getaddrinfo: Name or service not known (SocketError)
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/puma-3.8.2/lib/puma/binder.rb:269:in `new'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/puma-3.8.2/lib/puma/binder.rb:269:in `add_tcp_listener'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/puma-3.8.2/lib/puma/binder.rb:105:in `block in parse'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/puma-3.8.2/lib/puma/binder.rb:88:in `each'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/puma-3.8.2/lib/puma/binder.rb:88:in `parse'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/puma-3.8.2/lib/puma/runner.rb:144:in `load_and_bind'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/puma-3.8.2/lib/puma/single.rb:87:in `run'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/puma-3.8.2/lib/puma/launcher.rb:172:in `run'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/puma-3.8.2/lib/rack/handler/puma.rb:64:in `run'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/rack-2.0.1/lib/rack/server.rb:296:in `start'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/railties-5.1.0.rc1/lib/rails/commands/server/server_command.rb:44:in `start'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/railties-5.1.0.rc1/lib/rails/commands/server/server_command.rb:130:in `block in perform'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/railties-5.1.0.rc1/lib/rails/commands/server/server_command.rb:125:in `tap'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/railties-5.1.0.rc1/lib/rails/commands/server/server_command.rb:125:in `perform'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/railties-5.1.0.rc1/lib/rails/command/base.rb:63:in `perform'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/railties-5.1.0.rc1/lib/rails/command.rb:44:in `invoke'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/railties-5.1.0.rc1/lib/rails/commands.rb:16:in `<top (required)>'
        from /home/chris/Projects/cwatsondev-api/bin/rails:9:in `require'
        from /home/chris/Projects/cwatsondev-api/bin/rails:9:in `<top (required)>'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
        from /home/chris/.rvm/gems/ruby-2.4.0/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
        from /home/chris/Projects/cwatsondev-api/bin/spring:15:in `require'
        from /home/chris/Projects/cwatsondev-api/bin/spring:15:in `<top (required)>'
        from bin/rails:3:in `load'
        from bin/rails:3:in `<main>'

      

I've never seen an error like this when a rails server was running before. I am using Rails 5.1.0.rc1 in OpenSuse Tumbleweed. It seems to me that the problem is with the hostname linux-my4o.

+3


source to share


2 answers


I understood that. I just needed to add a new line to my file etc/hosts

.



127.0.0.1 linux-my4o

+2


source


I fixed mine by adding the following lines to my environment variables. For Linux, I added the following line

export HOST="localhost"

      



if that doesn't work, especially if rails is complaining that the envvar is HOST

deprecated, use instead

export BINDING="localhost"

      

0


source







All Articles