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.
Related
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.
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
I built a rails app and successfully deployed it to heroku
Now I would like to access the development version to make changes on my local machine
When I rails s I get the error:
A server is already running. Check /home/username/myApp/tmp/pids/server.pid
That file has one line that reads 2673
What can I do to start the rails server while the app is hosted on heroku?
rm /home/username/myApp/tmp/pids/server.pid
Then
rails s
If it is not working
If you want to kill rails server process on port 3000 (which is what webrick normally uses), type this in your terminal to find out the PID of the process:
$ lsof -wni tcp:3000
Then, use the number in the PID column to kill the process:
$ kill -9 PID
Then
rails s
Hope you will be able to run rails server again in your local m/c
I'm new to Ruby and Rails. I start the WEBrick Server from scripts/server (via ./scripts/server from the directory created by rails) on Debian. The Server starts and is reachable, but if I press CTRL + C then appears
ERROR SystemExit: exit
[rails dir]/vendor/rails/railties/lib/commands/server.rb:106:in `exit'
and the Server won't stop. What goes wrong?
*nix
First step, lookup the process ID (PID) of rails server; you'll need the port it's running on.
Second step, manually kill the process using the PID obtained in step one.
sudo lsof -i tcp:<PORT> # e.g. 3000
kill -9 <PID> # e.g. 14319
For any latecomers, Rails 2.3.8 doesn't like Rack 1.2.1
Add gem 'rack', '1.1.0' to your gemfile, run bundle update rack and your server should exit correctly.
Try to find the process with ps aux in your terminal.
Then, kill -9 it.
Running Ubuntu Server 10.04 with Rails 2.3.4 and Webrick 1.3.1; our rails app runs fine when called via script/server -e production, but trying to test it as a daemon by calling it with the -d flag produces the following output:
=> Booting WEBrick
=> Rails 2.3.4 application starting on http://0.0.0.0:3000
Nothing is produced in the logs, and other Rails applications will run detached without issue.
I assume You are running the Webrick in port 3000
>>$ sudo netstat -anp | grep 3000
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 8822/ruby
>>$ sudo kill -9 8822
I don't mean to contradict your choosing Webrick as a production server and maybe there is something I'm missing about why you are choosing Webrick, but have you considered other alternatives? I'd wager you already know all of this, but Webrick is the provided ruby server, and it is also the slowest ruby server choice.
Some of the most popular production server choices are:
Passenger
Thin
Mongrel
Unicorn
Glassfish
Passenger is likely the most popular choice for production now due to its easy configuration, speed, and features.
If there is a specific use case for Webrick that makes it better than any of the other server choices, I'd love to know.
You can add patch to enable error log here: https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/core_ext/process/daemon.rb#L16
To
unless noclose
STDIN.reopen "/dev/null" # Free file descriptors and
STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
STDERR.reopen '/tmp/rails_daemon_err.log', 'a'
end
Now when you start rails server with -d, the error log will append to /tmp/rails_daemon.log.