# Bind failed

**URL:** <https://www.ruby-forum.com/t/bind-failed/243531>\
**Category:** NGINX\
**Created:** [December 2, 2015, 8:56am UTC](https://www.ruby-forum.com/t/bind-failed/243531 "2015-12-02T08:56:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [December 2, 2015, 8:56am UTC](https://www.ruby-forum.com/t/bind-failed/243531/1 "2015-12-02T08:56:13Z")

</div>

Hi,

I was doing some tests today and have created a single test virtual host  
with  
listen 8181;  
and nginx runs fine (1.9.7). Now if I change the listen to only one  
interface ip:  
listen 192.168.10.10:8181  
configtest shows fine but reload gives “bind failed” in the error log.  
Is this normal?

Thanks!  
Frank

---

<div class="post-metadata">

**Author:** ![fjlj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e79b87/32.png) [@fjlj](https://www.ruby-forum.com/u/fjlj)\
**Post date:** [December 2, 2015, 9:09am UTC](https://www.ruby-forum.com/t/bind-failed/243531/2 "2015-12-02T09:09:41Z")

</div>

Hello!

On Tue, Dec 01, 2015 at 12:49:50AM -0800, Frank L. wrote:

> Hi,
> 
> I was doing some tests today and have created a single test virtual host  
> with  
> listen 8181;  
> and nginx runs fine (1.9.7). Now if I change the listen to only one  
> interface ip:  
> listen 192.168.10.10:8181  
> configtest shows fine but reload gives “bind failed” in the error log.  
> Is this normal?

Short answer:

Yes, if you are using Linux.

Long answer:

Linux doesn’t allow listen sockets on INADDR\_ANY and an IP address  
on the same port to coexist, due to “security” reasons. And this  
is exactly what happens when you try to reload a configuration -  
nginx still has an open listening sockets on \*:8181 and tries to  
open another one on 192.168.10.10:8181. As a result, the bind()  
system call fails due to the Linux limitation, and that’s what you  
see in the error log. To switch from a listening on \* to an IP  
address on Linux you’ll have to restart nginx, reload won’t work.

The same process works fine on other OSes without such artificial  
limitations (e.g., FreeBSD).

–  
Maxim D.

> **[nginx](http://nginx.org/)**
