MBJH
MBJH

Reputation: 1639

Address already in use - bind(2) for 178.62.19.65:80 (Errno::EADDRINUSE), how do I restart unicorn on port80

I have done few alterations to my database but it is not reflected when I restart rails server. I use

 sudo service unicorn stop

and

 sudo service unicorn start

Unicorn starts but when I run the following line of code,

 root@moneytree:/home/zhall/zoulfia# rails s -p80 -e 
     production --   binding=moneytree.space

I get:

  => Booting Unicorn
   => Rails 4.2.0 application starting in production     
  on http://moneytree.space:80
  => Run `rails server -h` for more startup options
  => Ctrl-C to shutdown server 
  E, [2015-07-11T09:34:29.299617 #30491] ERROR -- 
  : adding listener failed addr=178.62.19.65:80 (in use)
  E, [2015-07-11T09:34:29.300071 #30491] ERROR -- 
  : retrying in 0.5 seconds (4 tries left)
  .........
  ...........
  Exiting
  /usr/local/rvm/gems/ruby-2.2.1/gems
  /unicorn-4.9.0/lib/unicorn/socket_helper.rb:185:in `bind': 
  Address already in use - bind(2) for 178.62.19.65:80 (Errno::EADDRINUSE)

Why doesn't unicorn port80 get refreshed? Any help would be very, very welcome.

Upvotes: 0

Views: 457

Answers (2)

MBJH
MBJH

Reputation: 1639

All I needed to do is to set the 'preload_app' to 'false' in my /etc/unicorn.config file. After that changes to application code were reflected when unicorn were restarted.

Upvotes: 1

Chol Nhial
Chol Nhial

Reputation: 1397

There's a program already running on port 80. Check with netstat netstat -ntl | grep -w 80. If you see a line with LISTEN then the port is already being used. Alternatively you could run rails on a different port as follows: rails s -p 8080 -e production

Upvotes: 0

Related Questions