Oops, I did it again
The following post is pretty much just for *nix and mac users. One of the things I did most often when I first started using mongrel for development was start some app up, forget which one and close my terminal window. Now the process was still running so I would get the following error when I tried to fire up my next app on the same port:
Address already in use - bind(2) (Errno::EADDRINUSE)
Being new to the command line, the only way I figured out how to stop it was restart my computer. So uncool, I know. Knowing that this is something newbs run into, I thought I would post a way to fix your problem without restarting.
Let’s say you start up your app like so:
$ mongrel_rails start -d
-d detaches the executed command from the current terminal but you can still find it in your processes list by typing:
$ ps aux
That will print out all of the currently running processes along with their PID (process identification number). On my system it spits out a big list so a simple trick to find the running mongrel process is:
$ ps aux | grep mongrel
The pipe (|) passes the output of
ps aux into the grep search for mongrel. Botta bing bang boom. You now have the process id number (and can do a simple kill to stop it).
If the PID was 933, you could:
You can now search for mongrel in the processes again and it should be gone. Note: If you used
script/server to start mongrel, you’ll have to grep that instead of mongrel:
ps aux | grep script/server