0

I've a problem starting my rails server using the command rails s. I'm using thin as my web server. Whenever I try to start the rails server, thin starts listening on port 3000 and then it calls eventmachine gem to start a server by calling start_tcp_server which gives me the error that something is already running on port 3000 which is, of course, the thin server. I've tried so many solutions out there on internet but nothing seems to work for me. There are so many questions on Stackoverflow as well related to this problem but nothing solved my problem. Please have a look at this paste: http://chopapp.com/#mtvadchu

UPDATE:

There was a problem with my /etc/hosts file. I had some invalid characters in my file i.e.

ahi 127.0.0.1    localhost

so the ahi part was not valid. I just removed those characters and everything got fine. So if anyone else encounters this problem, just make sure that your /etc/hosts file is valid.

Kashif Umair Liaqat
  • 1,064
  • 1
  • 18
  • 27
  • what happens if you call `rails s -p 4000` which will tell `thin` to run on port 4000 instead? – engineersmnky Mar 19 '15 at 13:26
  • I get the same error, no matter which port I use. Because thin is sending the same port to eventmachine. – Kashif Umair Liaqat Mar 19 '15 at 13:51
  • And you have tried this [SO Answer](http://stackoverflow.com/questions/9605430/thin-web-server-start-tcp-server-no-acceptor-runtimeerror-after-git-branch)? And checked that `tmp/pids/server.pid` does not exist? Please show what you have tried so we can get those out of the way. – engineersmnky Mar 19 '15 at 14:01
  • Yes, there are no files in `tmp/pids` folder. To be clear, I'm using RVM and I've another gemset for ruby 2.0.0 and rails 4.0 which is working fine. I just cloned the repository to another folder and upgraded the ruby and rails versions to 2.2.0 and 4.2 respectively. Now I'm unable to start the server in this new environment. P.S: I've tried all the solutions from the provided question link. – Kashif Umair Liaqat Mar 19 '15 at 14:15
  • Oh, I just missed one solution from that question and that very solution worked for me. Sorry for that but the solution for my problem is http://stackoverflow.com/a/20330258/1765499 I don't know why did this worked but it is.... – Kashif Umair Liaqat Mar 19 '15 at 14:20

1 Answers1

0

@KULKING, do one thing check whether your port 3000 is running or not by ->

$ lsof -i tcp:3000

****OR****

$ lsof -i tcp

If you think ruby is running previously on port 3000, kill that process by ->

$ kill -9 "pid"

And also checked that tmp/pids/server.pid does not exist? if it is then please delete the server.pid

Chitra
  • 1,294
  • 2
  • 13
  • 28
  • Hi, sorry that I didn't close the question but I already have solved it. The problem was with my `/etc/hosts` file. There were some characters before the local host mapping i.e. `ahi 127.0.0.1 localhost` which was the issue. I just removed `ahi` from the file and it started working :) – Kashif Umair Liaqat Mar 22 '15 at 13:05