I have a macbook pro os 10.6.6. When running rails server and load http://0.0.0.0:3000 the page tries to load for awhile then gives a "connection has timed out error". Has anyone had this problem before?
Thanks!
You're probably hitting another computer in your local network. See ↓.
Try http://localhost:3000/.
You can also try your actual IP address which you'll find in System Preferences > Network.
Make sure webrick is running. You should see a ruby process when you execute the following command.
ps aux | grep rails
Make sure webrick is listening on your localhost.
sudo lsof -i -P | grep -i "listen"
You should see something like
ruby 5710 username 7u IPv4 0x12d3b680 0t0 TCP *:3000 (LISTEN)
as the output. If you don't see it webrick is not running.
You can try running a different web server ie: ./script/server webrick instead of the default mongrel
Related
I'm trying to build a very simple service using Vapor. It depends on websockets, and I establish a connection between an iOS device in simulator and vapor running on localhost.
When I want to make changes to the server, I restart and sometimes get [ ERROR ] bind(descriptor:ptr:bytes:): Address already in use (errno: 48)
I don't know how to find and kill this process, which is a socket running on 8080. I have to restart to get out of it, and I feel like throwing the computer out the window after a few repetitions (question about that already asked in mentalHealthOverflow.com).
How can I find and kill this process? Stopping the simulator device doesn't do it.
The fix is actually pretty easy. Go to your terminal and run lsof -i :<port>, so in your case, lsof -i :8080. You will get an output of all the processes that are running on that port.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Run 48904 calebkleveter 31u IPv4 0x97c38af35a1b4785 0t0 TCP localhost:Run (LISTEN)
You can then run the kill command, passing in the PID from the output you got:
kill 48904
You can now run your Vapor service.
Oneliner that I use:
lsof -i :8080 -sTCP:LISTEN | awk 'NR > 1 {print $2}' | xargs kill -15
Which basically just sends PID of the Vapor process (running on the port 8080) to the kill command as argument
I am getting this error when attempting to start up a rails 4.1.1 server:
Listening on 0.0.0.0:3000, CTRL+C to stop
Exiting
/Users/darrenburgess/.rvm/gems/ruby-2.1.2#myflix/gems/eventmachine-1.0.0/lib/eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
I have tried the following commands to find and kill the process, however none of them reveal any servers running on 3000
ps ax | grep rails
ps ax | grep ruby
lsof -i TCP | grep LISTEN
lsof -i :3000
These, from my research on stack overflow, seem to be all of the available methods for discovering running ports.
In a rails 5 application I am getting the following similar error:
Listening on tcp://0.0.0.0:3000
Exiting
/Users/darrenburgess/.rvm/gems/ruby-2.3.1/gems/puma-3.7.0/lib/puma/binder.rb:269:in `initialize': Address already in use - bind(2) for "0.0.0.0" port 3000 (Errno::EADDRINUSE)
Note that I can start rails servers on other ports.
This error persists even after machine reboot. Seems I have exhausted all avenues for finding and killing ports in use. What other things can I try?
UPDATE:
#hjpotter92 suggests running:
netstat -lntp | grep 3000
This however does not work as an option is required for the p argument. According to man netstat the list of protocols is found in etc/protocols.
I looked in that file and found that tcp is a listed protocol. However, this command does not return any output:
netstat -lntp tcp | grep 3000
Nor does this command return anything either:
netstat -lnt | grep 3000
You can try scanning the port like this lsof -i :3000 and then kill the process using sudo kill -9 <PID>.
Well, it turns out the answer to this is fairly obscure. The Node instance of FileMaker server 16 is running on port 3000. I was running a FileMaker server on the my Rails development machine.
This command helped to discover that:
sudo lsof -P -i :3000
Result
node 562 fmserver 20u IPv6 0x3ef1908b38776fe5 0t0 TCP *:3000 (LISTEN)
I could kill that process, however elected instead to disable the Node instance (The FileMaker REST/Data API).
Documentation here shows that FileMaker 16 is using that port.
http://help.filemaker.com/app/answers/detail/a_id/16319
When starting the server in Cloud9, rails s -p $PORT -b $IP, I get an error and the server fails to start.
Address already in use - bind(2)
Following this post, Rails server says port already used, how to kill that process?,
I ran lsof -wni tcp:8080 (8080 because of cloud9)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ruby 18415 ubuntu 9u IPv4 698526934 0t0 TCP *:http-alt (LISTEN)
Then,
kill -18415 PID
But this results in an error,
bash: kill: 18415: invalid signal specification
Can anyone advise how to fix this error on Cloud9?
You're killing it with the wrong way.
You need to use:
kill -9 18415
9 - signal 'kill'
18415 - process id
Also you can kill all ruby processes like this:
killall -9 ruby
But use it only when you know what you're doing.
I Updated the output to make it more readable. Still getting this error.
Noob question. Has anyone else seen this error? This error seems to be spreading. It now happens for port 3000 and 3001. If I change the code and debug settings to 3002 then I can continue debugging.
--------------------------------------------------------------
-------------------------------------------------------------
$: rails s -p 3000
=> Booting Thin
=> Rails 3.2.11 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
Exiting
/home/xxx/.rvm/gems/ruby-1.9.3-p551#ats/gems/eventmachine-1.0.8/lib/eventmachine.rb:534:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
run
ps ax | grep rails
this will return the process number of the rails server currently running
then you can do
kill -9 *process_numer*
this answer assumes that you accidentally quit rails server by pressing Ctrl+Z instead of Ctrl+C which did no dispose of the process properly and is now tying up the port.
This error occurs when some process is already using that port.
Usually this happens when rails server is already started (for example - for other project, and you forgot to stop it)
Use ps ax | grep rails | grep -v grep and lsof -n -i4TCP:3000 | grep LISTEN to find rails servers and processes using port 3000
After deleting the file Server.pids as instructed in the below link, I still can not run my app. Please see at the end of this message the output in terminal.
How can I solve this?
Thanks
Link:
Server is already running in Rails
New error in terminal (Mac):
Exiting
/Users/agustinguerrero/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/socket.rb:206:in `bind': Address already in use - bind(2) for 0.0.0.0:3000 (Errno::EADDRINUSE)
You are getting this error because another server is really running - try running localhost:3000 in your browser.
It doesn't need to be the same rails app - it is simply saying that port 3000 is already taken. You might:
Restart your machine
Run app on different port: rails s -p 3001 #or other port
Find what is taking port 3000 and kill it (you must be sure it is ok to kill it first though):
fuser -n tcp 3000 #=> 3000/tcp: xxxx
kill xxxx
Kill the already running instance by getting the pid through:
ps aux | grep rails
Then kill it