bjork24
bjork24

Reputation: 3183

Starting rails server always throws socket error

Nine times out of ten, whenever I start either the default rails webrick server, or thin server, I get a socket error. I have to do lsof | grep IPv4, find the ruby process, then kill -9 the PID. It seems like I'm doing this all the time... is there not a permanent solution to this? Is it b/c I sometimes close the terminal window without control+C'ing the server instance?

Upvotes: 1

Views: 583

Answers (2)

Bijendra
Bijendra

Reputation: 10015

Aso if you can use rails s -p x .In this x is port no 3000 or 3001 etc.you will not get any bind error if ctrl + c is not pressed to close the server.Also it's better to use ctrl + c to close the server

Upvotes: 0

Brett Bender
Brett Bender

Reputation: 19738

Yes, it is probably because you are not killing the server instance. By default, the server listens on localhost:3000, so if the process is still alive after you quit your terminal, it is still occupying the port, and attempting to start another server will fail. Just control-c your servers before you close the terminal session and you shouldn't have any more issues.

Upvotes: 2

Related Questions