I am running rails application by calling "rails server". I use ssh client to connect to aws. The ssh client connection to aws always auto logout. The message is "Connection reset by 13.250.214.114 port 22". When auto logout, the "rails server" is killed.
Could i stop aws from killing the rails application ?
Instead of
rails server
do:
rails s -d
then to kill it, find which process is using the port:
lsof -i :3000
finally, kill the process:
kill -9 $(lsof -i :3000 -t)
Create aliases:
alias startRails='rails server -d'
alias stopRails='kill -9 $(lsof -i :3000 -t)'
Source
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 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
I've tried to kill my rails server using this article from cloud 9.
I'm using the gem thin and everytime I try to run cloud server command I recieve this error
rails s -b $IP -p $PORT
=> Booting Thin
=> Rails 4.2.6 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
=> 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:8080, CTRL+C to stop
Exiting
/usr/local/rvm/gems/ruby-2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:530:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
from /usr/local/rvm/gems/ruby-2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:530:in `start_server'
from /usr/local/rvm/gems/ruby-2.3.0/gems/thin-1.6.4/lib/thin/backends/tcp_server.rb:16:in `connect'
from /usr/local/rvm/gems/ruby-2.3.0/gems/thin-
full error
It seems the port 8080 is in use, to find the PID using the port, run :
netstat -tulpn | grep :8080
Then you can kill -9 <PID>
This error says, 8080 port already in use, you may need to use different port for you application
Update:
Try to kill the existing process. Find port number using this command ps -ef | grep thin and then kill it kill -9 <port>. Try running your app now.
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
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