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
Related
I need to start a rails server on Travis to run integration tests.
I've added this to the config file:
before_script:
- psql -c 'create database scalia_test;' -U postgres
- "bundle exec rails server -p 3000 &"
However, I still get an error from Cypress:
http://localhost:3000/users/sign_in
We attempted to make an http request to this URL but the request failed without a response.
We received this error at the network level:
> Error: connect ECONNREFUSED 127.0.0.1:3000
Common situations why this would fail:
- you don't have internet access
- you forgot to run / boot your web server
- your web server isn't accessible
- you have weird network configuration settings on your computer
The stack trace for this error is:
Error: connect ECONNREFUSED 127.0.0.1:3000
at Object.exports._errnoException (util.js:1024:11)
at exports._exceptionWithHostPort (util.js:1047:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1150:14)
Does anybody knows how to start a Rails server on Travis ?
You are using & to send the command to the background, then you are running your tests right?
By the time you are running the tests Travis is still booting up your Rails server in the background therefore it's erroring out saying it can't connect. In my opinion it doesn't have to do anything with port binding.
In order to fix that you should use the -d parameter to daemonize rails after it started:
before_script:
- psql -c 'create database scalia_test;' -U postgres
- "bundle exec rails server -p 3000 -d"
rails server will block until it listens on port 3000 then sends itself to the background and continue running your scripts.
Do note that after your tests have run you may kill the rails server again using:
kill -9 $(cat tmp/pids/server.pid)
Otherwise you'll get a timeout or another error from travis.
Try binding rails to the loopback IP in that port
bundle exec rails s -p 3000 -b 127.0.0.1
probably that port is in use. Type lsof -i :8000 in terminal to see if that port is beeing used
U can try to start server with difrent port like rails server -p 3050
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
I would like to redirect 192.168.199.128 to localhost on OSX Yosemite. I'm running a Rails server on port 3000 and I would like to access it using localhost:3000/home as well as 192.168.199.128:3000/home.
I understand that iptables was removed in OSX Yosemite and pf is the preferred method of doing port forwarding but I'm unable to get it working.
This appears in /etc/pf.anchors/com.analysis, with a newline below it
rdr pass on lo8 proto tcp from any to 192.168.199.128 port 3000 -> 127.0.0.1 port 3000
Additionally, I added the following line to the end of /etc/pf.conf
load anchor "com.analysis" from "/etc/pf.anchors/com.analysis"
Finally, I started pf with the following command:
sudo pfctl -ef /etc/pf.anchors/com.analysis
Unfortunately, I still cannot access my rails server at 192.168.199.128:3000/home.
Thanks in advance for your help.
rails server -b 192.xxx.xxx.xxx
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