7

So im using ruby on rails in windows (i hear you all spitting your coffee onto the screen), its only a short term thing. (using ubuntu at home) So i tried to fire up webrick this afternoon and i get the error message

TCPServer Error, only one usage of each socket address is normally permitted

So it seems as if port 3000 is still running from last week? My question is how do i kill the process from the Windows command line. normally i have to press ctrl and pause/break in windows as ctrl c is not working which is only killing the batch process it seems..

Any solutions welcomed

Edit

So it seems as if

tasklist 

will give me the list of processes, but where do i find the process for running the webrick server?

ruby.exe is not listed as a running process

Community
  • 1
  • 1
Richlewis
  • 13,978
  • 32
  • 103
  • 238

2 Answers2

14

Try using netstat -a -o -n to determine the pid of the process running on port 3000. Then you should be able to use taskkill /pid #### to kill whatever process is running on that port.

Probably not the most graceful way to do it, but I think it should work.

EDIT

You'll probably have to also use the /F flag to force-kill the process. I just tried it on my local machine, and that worked fine.

Zajn
  • 3,968
  • 21
  • 38
  • thank you very much, been searching everywhere for that, yeah im getting access denied, is the syntax taskkill /F pid ### – Richlewis Dec 03 '12 at 14:42
  • 1
    yeah, that should do it. So if `netstat` shows a pid of `6688`, then the command would be `taskkill /F /pid 6688`. Also, I tried running it from Git Bash to no avail. Works fine under command prompt though. – Zajn Dec 03 '12 at 14:49
  • Make sure you're putting a space between those flags! `taskkill /F /pid ####` – Zajn Dec 03 '12 at 16:10
  • yes it was my spacing, the command is correct but i am getting access denied so the process cannot be terminated.Would you happen to know why this is? – Richlewis Dec 04 '12 at 08:10
  • its ok i opened up cmd with ctrl shift enter..This gave me admin privelages – Richlewis Dec 04 '12 at 08:24
  • Be careful. When you forcibly kill the Rails server this way you'll need to ensure you delete `\tmp\pids\server.pid` afterwards if you intend to start the Rails server again. – Ben Jan 16 '15 at 15:21
2

Go into rails_project\tmp\pids and delete the .pid file in there.

run:

rails server
partydog
  • 182
  • 1
  • 11