# Address already in use - bind(2) (Errno::EADDRINUSE)

**URL:** <https://www.ruby-forum.com/t/address-already-in-use-bind-2-errno-eaddrinuse/207100>\
**Category:** Rails\
**Created:** [May 18, 2011, 11:27am UTC](https://www.ruby-forum.com/t/address-already-in-use-bind-2-errno-eaddrinuse/207100 "2011-05-18T11:27:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [May 18, 2011, 11:27am UTC](https://www.ruby-forum.com/t/address-already-in-use-bind-2-errno-eaddrinuse/207100/1 "2011-05-18T11:27:21Z")

</div>

I made a new rails app and when i started the server ,it gave  
following error message.

=\> Booting Mongrel  
=\> Rails 2.3.8 application starting on [http://0.0.0.0:3000](http://0.0.0.0:3000)  
=\> Call with -d to detach  
=\> Ctrl-C to shutdown server  
Exiting  
/usr/lib/ruby/1.8/mongrel/tcphack.rb:12:in  
`initialize_without_backlog': Address already in use - bind(2) (Errno::EADDRINUSE) from /usr/lib/ruby/1.8/mongrel/tcphack.rb:12:in `initialize’  
from /usr/lib/ruby/1.8/mongrel.rb:93:in `new' from /usr/lib/ruby/1.8/mongrel.rb:93:in `initialize’  
from /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/handler/mongrel.rb:  
10:in `new' from /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/handler/mongrel.rb: 10:in `run’  
from /var/lib/gems/1.8/gems/rails-2.3.8/lib/commands/server.rb:111  
from /usr/lib/ruby/1.8/rubygems/custom\_require.rb:31:in  
`gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require’  
from script/server:3

Please help to resolve.

Thanks.

---

<div class="post-metadata">

**Author:** ![amritpal\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/71c47a/32.png) [@amritpal\_p](https://www.ruby-forum.com/u/amritpal_p)\
**Post date:** [May 18, 2011, 11:37am UTC](https://www.ruby-forum.com/t/address-already-in-use-bind-2-errno-eaddrinuse/207100/2 "2011-05-18T11:37:14Z")

</div>

Hi Amrit,

You cannot run two application on the same port. One of your application  
is  
already running using port 3000. And you are trying to run another  
application on the same port.

If you want to run another application, then use the following command  
to do  
that:

rub script/server -p 3001

where 3001 is the port number. You choose any other ports also.

Ankit

On Wed, May 18, 2011 at 2:56 PM, amrit pal pathak  
\<removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![amritpal\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/71c47a/32.png) [@amritpal\_p](https://www.ruby-forum.com/u/amritpal_p)\
**Post date:** [May 18, 2011, 11:38am UTC](https://www.ruby-forum.com/t/address-already-in-use-bind-2-errno-eaddrinuse/207100/3 "2011-05-18T11:38:29Z")

</div>

On 18 May 2011, at 11:26, amrit pal pathak wrote:

> `initialize_without_backlog': Address already in use - bind(2) `gem\_original\_require’  
> from /usr/lib/ruby/1.8/rubygems/custom\_require.rb:31:in `require’  
> from script/server:3
> 
> Please help to resolve.

You already have a server running on port 3000. Probably another  
Webrick server you started earlier in a different terminal window. It  
even says so: Address already in use. I don’t see how it could be any  
more obvious.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![amritpal\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/71c47a/32.png) [@amritpal\_p](https://www.ruby-forum.com/u/amritpal_p)\
**Post date:** [May 20, 2011, 4:04pm UTC](https://www.ruby-forum.com/t/address-already-in-use-bind-2-errno-eaddrinuse/207100/4 "2011-05-20T16:04:41Z")

</div>

On May 18, 5:37am, Peter De Berdt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > I made a new rails app and when i started the server ,it gave  
> > from /usr/lib/ruby/1.8/mongrel/tcphack.rb:12:in `initialize’  
> > from script/server:3
> 
> > Please help to resolve.
> 
> You already have a server running on port 3000. Probably another  
> Webrick server you started earlier in a different terminal window. It  
> even says so: Address already in use. I don’t see how it could be any  
> more obvious.  
> Is there any way to check,how many ports are already in use,so  
> that i can stop the application which are already running on those.?

Thanks

---

<div class="post-metadata">

**Author:** ![amritpal\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/71c47a/32.png) [@amritpal\_p](https://www.ruby-forum.com/u/amritpal_p)\
**Post date:** [May 20, 2011, 4:12pm UTC](https://www.ruby-forum.com/t/address-already-in-use-bind-2-errno-eaddrinuse/207100/5 "2011-05-20T16:12:06Z")

</div>

on linux - “lsof | grep -i ruby”

tom

On May 20, 2011, at 16:03 , amrit pal pathak wrote:

> > > /usr/lib/ruby/1.8/mongrel/tcphack.rb:12:in  
> > > from /usr/lib/ruby/1.8/rubygems/custom\_require.rb:31:in  
> > > Is there any way to check,how many ports are already in use,so  
> > > that i can stop the application which are already running on those.?
> 
> Thanks
> 
> –  
> You received this message because you are subscribed to the Google G. “Ruby  
> on Rails: Talk” group.  
> To post to this group, send email to [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> To unsubscribe from this group, send email to  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
Maxwell Render CZ  
Autorizovany distributor Maxwell renderu pro Ceskou republiku

---

<div class="post-metadata">

**Author:** ![amritpal\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/71c47a/32.png) [@amritpal\_p](https://www.ruby-forum.com/u/amritpal_p)\
**Post date:** [November 24, 2013, 10:15pm UTC](https://www.ruby-forum.com/t/address-already-in-use-bind-2-errno-eaddrinuse/207100/6 "2013-11-24T22:15:35Z")

</div>

I agree with Peter De Berdt …

Another webrick server is still running

Just close the shell and reopen it…

and then run

‘rails server’ again

---

<div class="post-metadata">

**Author:** ![amritpal\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/71c47a/32.png) [@amritpal\_p](https://www.ruby-forum.com/u/amritpal_p)\
**Post date:** [November 25, 2013, 10:03am UTC](https://www.ruby-forum.com/t/address-already-in-use-bind-2-errno-eaddrinuse/207100/7 "2013-11-25T10:03:09Z")

</div>

you can check which process is running on that port by typing on command  
line

lsof -i tcp:port number and than kill that process by typing  
kill -9 process#

and that start the rails server -p 3000

---

<div class="post-metadata">

**Author:** ![amritpal\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/71c47a/32.png) [@amritpal\_p](https://www.ruby-forum.com/u/amritpal_p)\
**Post date:** [November 25, 2013, 12:21pm UTC](https://www.ruby-forum.com/t/address-already-in-use-bind-2-errno-eaddrinuse/207100/8 "2013-11-25T12:21:39Z")

</div>

On 25 November 2013 09:02, Fahad I. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > I agree with Peter De Berdt ..
> > 
> > Another webrick server is still running

Did you all realise you are responding to a post from 2011?

Colin

---

<div class="post-metadata">

**Author:** ![amritpal\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/71c47a/32.png) [@amritpal\_p](https://www.ruby-forum.com/u/amritpal_p)\
**Post date:** [December 9, 2011, 12:27am UTC](https://www.ruby-forum.com/t/address-already-in-use-bind-2-errno-eaddrinuse/207100/9 "2011-12-09T00:27:38Z")

</div>

> on linux - “lsof | grep -i ruby”

I would like to recommend:  
lsof -i :3000  
(given that the zombie server is running on port 3000)

and then to check a reported :  
ps ax | grep

before final:  
kill -QUIT

---

<div class="post-metadata">

**Author:** ![amritpal\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/71c47a/32.png) [@amritpal\_p](https://www.ruby-forum.com/u/amritpal_p)\
**Post date:** [November 26, 2013, 4:47am UTC](https://www.ruby-forum.com/t/address-already-in-use-bind-2-errno-eaddrinuse/207100/10 "2013-11-26T04:47:21Z")

</div>

On Nov 25, 2013, at 5:19 AM, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > On Mon, Nov 25, 2013 at 2:15 AM, Agu N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> > 
> > > I agree with Peter De Berdt ..
> > > 
> > > Another webrick server is still running
> 
> Did you all realise you are responding to a post from 2011?
> 
> Colin

Gmail Random Delivery strikes again!
