I'm trying to learn Rails from the Rails Tutorial book, got lubuntu so I could try to get the best experience possible. Now I'm stuck on something that should be easy and straight forward.
We're creating a little "toy app" a very basic twitter like thing, still at the very beginning, we used:
$ rails generate scaffold User name:string email:string
To generate a User Table if I'm not mistaken and then:
$ rails db:migrate
I guess to update a preexisting table structure (not sure, but it's said that later everything will be explained).
Finally we are supposed to run this:
$ rails server -b $IP -p $PORT
In a differente tab, I did and got this error:
~/workspace/toy_app$ rails server -b $IP -p $PORT
=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://-p:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.4.0 (ruby 2.3.1-p112), codename: Owl Bowl Brawl
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://-p:3000
Exiting
/var/lib/gems/2.3.0/gems/puma-3.4.0/lib/puma/binder.rb:255:in `initialize': getaddrinfo: Name or service not known (SocketError)
from /var/lib/gems/2.3.0/gems/puma-3.4.0/lib/puma/binder.rb:255:in `new'
from /var/lib/gems/2.3.0/gems/puma-3.4.0/lib/puma/binder.rb:255:in `add_tcp_listener'
from /var/lib/gems/2.3.0/gems/puma-3.4.0/lib/puma/binder.rb:102:in `block in parse'
from /var/lib/gems/2.3.0/gems/puma-3.4.0/lib/puma/binder.rb:85:in `each'
from /var/lib/gems/2.3.0/gems/puma-3.4.0/lib/puma/binder.rb:85:in `parse'
from /var/lib/gems/2.3.0/gems/puma-3.4.0/lib/puma/runner.rb:129:in `load_and_bind'
from /var/lib/gems/2.3.0/gems/puma-3.4.0/lib/puma/single.rb:84:in `run'
from /var/lib/gems/2.3.0/gems/puma-3.4.0/lib/puma/launcher.rb:172:in `run'
from /var/lib/gems/2.3.0/gems/puma-3.4.0/lib/rack/handler/puma.rb:51:in `run'
from /var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/server.rb:296:in `start'
from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/server.rb:79:in `start'
from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:90:in `block in server'
from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from /home/zero/workspace/toy_app/bin/rails:9:in `require'
from /home/zero/workspace/toy_app/bin/rails:9:in `<top (required)>'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `load'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `call'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/command.rb:7:in `call'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/client.rb:30:in `run'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/bin/spring:49:in `<top (required)>'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `load'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `<top (required)>'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/zero/workspace/toy_app/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
Is anything corrupted? Did I do anything wrong? I went to check the files I remembered seeing puma (in the app folder) on and it's in the gem file:
gem 'puma', '3.4.0'
And the puma.rb file (took out the comments):
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
port ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }
plugin :tmp_restart
I was going to put all the files mentioned but it's tons of code, if there's any that's useful I'll post it, I don't want to spam with possible useless code.
$IP is not defined in your environment, so rails server is trying to use -p as the IP address. Try this:
rails server -b ${IP:-127.0.0.1} -p ${PORT:-3000}
Alternatively, set these environment variables with export before running rails server -b $IP -p $PORT:
export IP=127.0.0.1
export PORT=3000
Or if you're fine with Rails' defaults, just forget all this and run rails server. :-)
If you are running locally you should be able to use rails server without arguments. If you are using the Hartl tutorial, it presumes you are using a web-based IDE that requires the extra arguments.
If you are using cloud based IDE, you need to listen at particular IP & PORT. For example, C9, you need to listen to 0.0.0.0 and 8080. So they have setup environment variables, $IP & $PORT.
If you execute,
echo $IP ###gives 0.0.0.0
echo $PORT ###gives 8080
rails s -b $IP -p $PORT ##Rails x.x.x application starting in development on http://0.0.0.0:8080
The -b option binds Rails to the specified IP, by default it is localhost.
If you are on your local machine, run
rails s ### Rails x.x.x application starting in development on http://localhost:3000
Related
I have had this problem for a while but have found no solution. I am building a forums application in rails. I had just finished adding bootstrap and the bootstrap gem to my project. I go to run the server and it exits with a huge error. Here it is.
Julies-MacBook-Air:railsnew juliechopourian$ rails server
=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://localhost:3000
=> Runrails server -hfor more startup options
Puma starting in single mode...
* Version 3.6.0 (ruby 2.3.1-p112), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Exiting
/Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:266:ininitialize': Address already in use - bind(2) for "::1" port 3000 (Errno::EADDRINUSE)
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:266:in new'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:266:inadd_tcp_listener'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:260:in block in add_tcp_listener'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:259:ineach'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:259:in add_tcp_listener'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:102:inblock in parse'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:85:in each'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:85:inparse'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/runner.rb:133:in load_and_bind'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/single.rb:85:inrun'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/launcher.rb:172:in run'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/rack/handler/puma.rb:51:inrun'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rack-2.0.1/lib/rack/server.rb:296:in start'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/server.rb:79:instart'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:90:in block in server'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:intap'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in server'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:inrun_command!'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in <top (required)>'
from /Users/juliechopourian/treehouse/rails_app/railsnew/bin/rails:9:inrequire'
from /Users/juliechopourian/treehouse/rails_app/railsnew/bin/rails:9:in <top (required)>'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:inload'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in call'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/command.rb:7:incall'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/client.rb:30:in run'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/bin/spring:49:in'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in load'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require'
from /Users/juliechopourian/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /Users/juliechopourian/treehouse/rails_app/railsnew/bin/spring:13:in <top (required)>'
from bin/rails:3:inload'
from bin/rails:3:in <main>'
Julies-MacBook-Air:railsnew juliechopourian$
I think it might have something to do with the puma gem but I really don't know. Any help would be very appreciated. Tell me if I need to post any more of my project.
rails 5
ps aux | grep 3000
if rails app still running
user 3454 0.6 5.6 1708124 220676 pts/5 Sl+ 20:18 0:20 puma 3.6.0 (tcp://localhost:3000)
kill -9 3454
or
rails s -p 3001
Watch this Address already in use - bind(2) for "::1" port 3000 (Errno::EADDRINUSE)
Something is already listening on port 3000. Be sure you don't have other ruby processes listening to that port. Something like
ps aux | grep ruby
When trying to start my Rails app in C9.io, I see the Socket Error below. I am unsure how to correct this issue. Any ideas?
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
Rails 4.2.5
Cloud9 IDE
blacknight659:~/jh_projects/mybay2 $ rails s -b -$IP -p -$PORT
=> Booting WEBrick
=> Rails 4.2.5 application starting in development on http://-0.0.0.0:-8080
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
[2016-07-26 17:43:06] INFO WEBrick 1.3.1
[2016-07-26 17:43:06] INFO ruby 2.3.0 (2015-12-25) [x86_64-linux]
Exiting
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/socket.rb:231:in getaddrinfo': getaddrinfo: Servname not supported for ai_socktype (SocketError)
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/socket.rb:231:inforeach'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/socket.rb:757:in tcp_server_sockets'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/webrick/utils.rb:65:increate_listeners'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/webrick/server.rb:134:in listen'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/webrick/server.rb:115:ininitialize'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/webrick/httpserver.rb:47:in initialize'
from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:31:innew'
from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:31:in run'
from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/server.rb:286:instart'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/server.rb:80:in start'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:inblock in server'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in tap'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:inserver'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in run_command!'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in'
from /home/ubuntu/jh_projects/mybay2/bin/rails:9:in require'
from /home/ubuntu/jh_projects/mybay2/bin/rails:9:in'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in load'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:incall'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/client/command.rb:7:in call'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/client.rb:30:inrun'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/bin/spring:49:in <top (required)>'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:inload'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in <top (required)>'
from /home/ubuntu/jh_projects/mybay2/bin/spring:13:inrequire'
from /home/ubuntu/jh_projects/mybay2/bin/spring:13:in <top (required)>'
from bin/rails:3:inload'
from bin/rails:3:in `'
I got the same error when tried to start my Sinatra app on cloud9. It turned out that I was running the command : $ bundle exec rackup -p $PORT -o $IP with root user (su). Try to run it on normal user.
You have a dash before ip and port arguments. The values of the arguments are specified without dashes. Try:
rails s -b $IP -p $PORT
I am getting the following error when starting my rails application in developemnt
bundle exec rails s -e development 3010
error:
Exiting
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.0.6/lib/active_support/dependencies.rb:229:in `require': cannot load such file -- rack/handler/3010 (LoadError)
from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.0.6/lib/active_support/dependencies.rb:229:in `block in require'
from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.0.6/lib/active_support/dependencies.rb:214:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.0.6/lib/active_support/dependencies.rb:229:in `require'
from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.5/lib/rack/handler.rb:76:in `try_require'
from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.5/lib/rack/handler.rb:16:in `get'
from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.5/lib/rack/server.rb:268:in `server'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.0.6/lib/rails/commands/server.rb:63:in `start'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.0.6/lib/rails/commands.rb:76:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.0.6/lib/rails/commands.rb:71:in `tap'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.0.6/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Can't figure out the problem.
Have you tried with:
rails s -p 3010
By default, it works in development environment.
And if you still want to run with this statement, then try:
bundle exec rails s -e development -p 3010
You are missing -p here.
You can be using the below comment,
rails s -p whatever_you_want
Here -p indigates the port number of the app
Example: rails s -p 8030 // Here 8030 is the port number
If you want to run the rails app means, execute the below URL,
bundle exec rails s -e development -p 8030
Here -e refers the environment you are going run the rails app.
Im trying to get started learning Ruby on Rails and I'm having an issue getting server to start or stop correctly and I'm not sure why.
As i understand it, when i start a server up it will run until i hit Ctrl + C to shut it down.
However if i run bin/rails server to start it up it says there is already a server running at port 3000 so i need to use a different port, which ive done below. I don't want to keep making new ports each time.
What am i doing wrong folks?
Gavins-MacBook-Pro:buro MacBook$ bin/rails server -p 3001
=> Booting WEBrick
=> Rails 4.2.1 application starting in development on http://localhost:3001
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
A server is already running. Check /Users/MacBook/buro/tmp/pids/server.pid.
Exiting
Gavins-MacBook-Pro:buro MacBook$
Gavins-MacBook-Pro:buro MacBook$ bin/rails server -p 3001
=> Booting WEBrick
=> Rails 4.2.1 application starting in development on http://localhost:3001
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
A server is already running. Check /Users/MacBook/buro/tmp/pids/server.pid.
Exiting
Gavins-MacBook-Pro:buro MacBook$ bin/rails server -p 3002
=> Booting WEBrick
=> Rails 4.2.1 application starting in development on http://localhost:3002
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
A server is already running. Check /Users/MacBook/buro/tmp/pids/server.pid.
Exiting
Gavins-MacBook-Pro:buro MacBook$
Also i tried removing the pid file but then i still get this:
Gavins-MacBook-Pro:buro MacBook$ bin/rails server
=> Booting WEBrick
=> Rails 4.2.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-07-24 10:58:14] INFO WEBrick 1.3.1
[2015-07-24 10:58:14] INFO ruby 2.2.2 (2015-04-13) [x86_64-darwin14]
Exiting
/Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/2.2.0/socket.rb:206:in `bind': Address already in use - bind(2) for 127.0.0.1:3000 (Errno::EADDRINUSE)
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/2.2.0/socket.rb:206:in `listen'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/2.2.0/socket.rb:461:in `block in tcp_server_sockets'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/2.2.0/socket.rb:232:in `each'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/2.2.0/socket.rb:232:in `foreach'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/2.2.0/socket.rb:459:in `tcp_server_sockets'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/utils.rb:70:in `create_listeners'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/server.rb:133:in `listen'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/server.rb:114:in `initialize'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:45:in `initialize'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:31:in `new'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:31:in `run'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:286:in `start'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/server.rb:80:in `start'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `server'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/MacBook/buro/bin/rails:8:in `require'
from /Users/MacBook/buro/bin/rails:8:in `<top (required)>'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/client/rails.rb:28:in `load'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/client/rails.rb:28:in `call'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/client/command.rb:7:in `call'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/client.rb:26:in `run'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/bin/spring:48:in `<top (required)>'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/binstub.rb:11:in `load'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/binstub.rb:11:in `<top (required)>'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/MacBook/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/MacBook/buro/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
Do
ps ax | grep server
and look for your rails servers. The first number in each result line is the process id, aka "pid". You can kill these processes like
kill -9 12345
where 12345 is an example pid.
Kill them all and then do
rm tmp/pids/server.pid
for good measure. These are all done in Terminal by the way, in your application's root folder (where you run the server from).
https://www.railstutorial.org/book/beginning#sec-rails_server
I have reached this step, and I'm using the cloud9 environment. When I run the server as per Listing 1.7 on that tutorial, however, I get this error:
myname#rails-tutorial:~/workspace/hello_app $ rails server -p $PORT -b $IP
=> Booting WEBrick
=> Rails 4.2.0.beta2 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-10-30 21:44:22] INFO WEBrick 1.3.1
[2014-10-30 21:44:22] INFO ruby 2.1.1 (2014-02-24) [x86_64-linux]
Exiting /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/socket.rb:206:in `bind': Address already in use - bind(2) for 0.0.0.0:8080 (Errno::EADDRINUSE)
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/socket.rb:206:in `listen'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/socket.rb:461:in `block in tcp_server_sockets'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/socket.rb:232:in `each'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/socket.rb:232:in `foreach'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/socket.rb:459:in `tcp_server_sockets'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/utils.rb:75:in `create_listeners'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/server.rb:132:in `listen'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/server.rb:113:in `initialize'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:45:in `initialize'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/rack-1.6.0.beta/lib/rack/handler/webrick.rb:32:in `new'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/rack-1.6.0.beta/lib/rack/handler/webrick.rb:32:in `run'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/rack-1.6.0.beta/lib/rack/server.rb:288:in `start'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/railties-4.2.0.beta2/lib/rails/commands/server.rb:80:in `start'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:75:in `server'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/railties-4.2.0.beta2/lib/rails/commands.rb:17:in `<top (required)>'
from /home/ubuntu/workspace/hello_app/bin/rails:8:in `require'
from /home/ubuntu/workspace/hello_app/bin/rails:8:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `load'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `call'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
from /usr/local/rvm/gems/ruby-2.1.1#rails4/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
from /home/ubuntu/workspace/hello_app/bin/spring:16:in `require'
from /home/ubuntu/workspace/hello_app/bin/spring:16:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
I've tried specifying a different port, but that doesn't work and the cloud9 environment suggests to me I should just use the $PORT variable.
The error "Address already in use - bind(2) for 0.0.0.0:8080 (Errno::EADDRINUSE)" implies that I already have a rails server running, but I don't. I'm not really sure what to do here and the tutorial doesn't suggest any method of troubleshooting this issue.
I learned that you can use the command killall ruby to stop any of the ruby processes which helped me because I had mistakenly run the rails server -b $IP -p $PORT command at the ~/workspace level in the tutorial. I found the answer in can't open rails server
I ended up starting the tutorial from scratch again and it worked fine, but anyone with this problem in the future may find this troubleshooting technique I received from cloud9's support team useful:
Try:
lsof -i:8080
This will give the app that occupies it.
If apache, stop it using:
sudo /etc/init.d/apache2 stop
Hope this answer is of use to anyone with this problem.
Probably you just had the other server still running. The one you initiate earlier on in he tutorial with the rails server command. You need to shut the other one down first using Ctrl+C, then try rails server -b $IP -p $PORT again
$ rails server -b $IP -p $PORT
Cloud9 uses the special environment variables $IP and $PORT to assign
the IP address and port number dynamically. If you want to see the
values of these variables, type echo $IP or echo $PORT at the command
line.
It's likely that if you wait a few minutes (not more than 2), your OS will free up the port. If not, use a random port number over about 5,000 every time you run rails server, e.g.
$ rails server -b $IP -p 6789
Or, because your IDE is so sucky, you might consider using a different IDE.