Can't reach localhost via browser.Ruby on Rails - ruby-on-rails

I am new at RoR.
I've just installed RoR on my local computer,but I can't open localhost page with it.
After rails s command it showed to me this :
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
A server is already running. Check /home/roma/Templates/first_app/tmp/pids/server.pid.
Exiting
What could be a problem?

Check if the same app is already running. If not, simply delete the file located at /home/roma/Templates/first_app/tmp/pids/server.pid.

run kill -15 $(cat tmp/pids/server.pid ) from inside your project, e.g:
cd /home/roma/Templates/first_app/
kill -15 $(cat tmp/pids/server.pid )
That would kill the rails server running

Related

A server is already running. (Ruby on Rails)

I was practicing doing ruby on rails and I accidentally closed Visual Studio code while the terminal and rails server is running.
This is what happened after i typed rails s
PS C:\Users\Lenovo\Desktop\folder_name\project_name rails s
=> Booting Puma
=> Rails 6.1.4.1 application starting in development
=> Run `bin/rails server --help` for more startup options
A server is already running. Check C:/Users/Lenovo/Desktop/folder_name/project_name/tmp/pids/server.pid.
Exiting
Find the process id for the rails server port :
lsof -wni tcp:3000
Copy value in PID column
Kill the process (for example 14400) :
kill -9 14400
You can use this command to kill the server using port number.
sudo kill -9 $(lsof -i :3000 -t)
The user just needed to delete the server.pid file and it worked.

Michael Hatl's Rails Tutorial Chapter 2: Errno::ENOENT in UsersController#index when testing /users

When generating toy_app using scaffolding I can go to the root site using the local server, but when I try to go to the page /users I get the following error message: "Errno::ENOENT in UsersController#index"
The page should allow me to enter a new user.
When I try to restart the server and run rails server -b $IP -p $PORTI get the following:
sunny_dee#rails-tutorial:~/workspace/toy_app (master) $ rails server -b $IP -p $PORT
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-04-27 18:06:55] INFO WEBrick 1.3.1
[2015-04-27 18:06:55] INFO ruby 2.1.5 (2014-11-13) [x86_64-linux]
Exiting
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/socket.rb:206:in `bind': Address already in use - bind(2) for 0.0.0.0:8080 (Errno::EADDRINUSE)
I finally got it to work by restarting the workspace. I'm guessing that is what restarted the local server. I was trying Ctrl-C but it was not working.
The tutorial uses Cloud9 and since it's a cloud IDE closing/logging out did nothing but when I clicked on the button to the left of "Share" on the top right corner and the clicked on "Restart" the page ran correctly.
Hopefully my stupid question can help someone else as well. Thanks everyone that took the time to contribute :)
If you running this application in your local Linux system just use -
rails server
Then you can access your site using http://localhost:3000/
You can also specify which port to run on using this command -
rails s -p 3001 -P tmp/pids/server2.pid
Then you can access using 3001 port.
You are getting that error because your 8080 port is already in use by some other process.

ruby and rails server is already runing [duplicate]

This question already has answers here:
Server is already running in Rails
(20 answers)
Closed 8 years ago.
I want to start my server through this command but it show me warning server is all ready running. How can stop the server forcefully ?
jaskaran#jaskaran-Vostro-1550:~/rails_project$ rails s
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
A server is already running. Check /home/jaskaran/rails_project/tmp/pids/server.pid.
Exiting
if it is already running then it not working why?
Run this command:
ps ax | grep rails
This will show you the processes running having to do with Rails. The first number shown is the process ID. Look for the process that is running the Rails server, grab it's process ID, and type:
kill -9 processID
This will kill the Rails server that's running.
Run this command :-
ps aux | grep ruby
OR
ps -ef | grep ruby
It will show all the processes of ruby and also the running rails server
Then kill that processid as:-
kill -9 procesid
You can also remove the file inside:
/home/jaskaran/rails_project/tmp/pids/
i.e
server.pid
and start server again.

what can cause `rails s` to ignore the -e switch?

I'm seeing some strange behavior when I run Rails server with rails s -e [env] (double ** added for emphasis):
~/app> rails s -e=**production**# << ok...v
=> Booting Mongrel # v huh?
=> Rails 3.1.1 application starting in **test** on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
^CExiting
~/app> rails s -e=**development**
=> Booting Mongrel
=> Rails 3.1.1 application starting in **test** on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
^CExiting
~/app> RAILS_ENV=**development** rails s
=> Booting Mongrel
=> Rails 3.1.1 application starting in **development** on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
^CExiting
~/app> RAILS_ENV=**production** rails s
=> Booting Mongrel
=> Rails 3.1.1 application starting in **production** on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
The upshot is that the -e switch is being ignored.
The Rails guide doesn't mention any situations where it will be overriden. The command line help says -e Specifies the environment to run this server under test/development/production). OK.
I really think this was working fine a few weeks ago (been a while since I started a prod server on that box) so I may have changed something that broke this, but what? I checked for places where I was using = instead of == but didn't find any. Don't think that would explain this.
Update: John correctly points out that it is -e [env]. I tried that first with the same results then tried -e=[env]. The correct way (still produces incorrect result):
~/app> rails s -e production -p 5000
=> Booting Mongrel ^^^^^^^^^ vvvv
=> Rails 3.1.1 application starting in test on http://0.0.0.0:5000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Check that you don't have the RAILS_ENV environment variable set as it will override whatever you pass as a command line option.
The relevant bit of the rails source ydoes this
ENV["RAILS_ENV"] ||= options[:environment]
options is populated from the command line arguments, so if RAILS_ENV is already set your command line options have no effect.
It's rails s -e <env>, not rails s -e=<env>. Notice the space between -e and the name of the environment:
#Ψ rails s -e production
#=> Booting WEBrick vvvvvvvvvv
#=> Rails 3.1.1 application starting in production on http://0.0.0.0:3000
^^^^^^^^^^
#Ψ rails s -e staging
#=> Booting WEBrick vvvvvvv
#=> Rails 3.1.1 application starting in staging on http://0.0.0.0:3000
^^^^^^^

Unable to run ruby on rails app?

I am unable to run ruby on rails application. I setup the database and loaded database schema. When I run:
ruby script/server -e production
It says:
=> Booting Mongrel
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Crtl-C to shutdown server
and it just stays there. If I go to the directory where the app is installed, it just lists the directory of files and doesn't run the app. Any suggestions?
Thanks
Have you opened http://localhost:3000/ in a browser?
The '=> Booting Mongrel ...' stuff means the server is running, you just need to navigate a browser to it.
You are starting your server in production mode.
Use the development mode fpr debugging, it will give you a better log output.
Run ruby script/server -e development

Resources