# Problem upgrading on the fly when ipv6 is used

**URL:** <https://www.ruby-forum.com/t/problem-upgrading-on-the-fly-when-ipv6-is-used/189348>\
**Category:** NGINX\
**Created:** [May 29, 2010, 9:25am UTC](https://www.ruby-forum.com/t/problem-upgrading-on-the-fly-when-ipv6-is-used/189348 "2010-05-29T09:25:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Usu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/85f322/32.png) [@Usu](https://www.ruby-forum.com/u/Usu)\
**Post date:** [May 29, 2010, 9:25am UTC](https://www.ruby-forum.com/t/problem-upgrading-on-the-fly-when-ipv6-is-used/189348/1 "2010-05-29T09:25:04Z")

</div>

Hi!

I’ve always upgraded nginx on the fly following this guide:  
[CommandLine | NGINX](http://wiki.nginx.org/NginxCommandLine) without problems.  
I recently added IPv6 support to nginx and now, when I need to upgrade  
it, it doesn’t start the new instance when I send the USR2 signal to the  
master process, giving the following erros:

```auto
2010/05/29 09:05:52 [notice] 21060#0: using inherited sockets from 
"14;15;"
2010/05/29 09:05:52 [emerg] 21060#0: bind() to [2001:41d0:2:8673::1]:80 
failed (98: Address already in use)
[emerg]: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already 
in use)
2010/05/29 09:05:52 [emerg] 21060#0: bind() to [2001:41d0:2:8673::1]:80 
failed (98: Address already in use)
[emerg]: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already 
in use)
2010/05/29 09:05:52 [emerg] 21060#0: bind() to [2001:41d0:2:8673::1]:80 
failed (98: Address already in use)
[emerg]: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already 
in use)
2010/05/29 09:05:52 [emerg] 21060#0: bind() to [2001:41d0:2:8673::1]:80 
failed (98: Address already in use)
[emerg]: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already 
in use)
2010/05/29 09:05:52 [emerg] 21060#0: bind() to [2001:41d0:2:8673::1]:80 
failed (98: Address already in use)
[emerg]: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already 
in use)
2010/05/29 09:05:52 [emerg] 21060#0: still could not bind()
[emerg]: still could not bind()
```

I’m using nginx 0.8.37 and I was trying to upgrade to 0.8.38.  
Here’s an example of my nginx configuration regarding IPv6 (all the  
other vhost have the same one):

```auto
    server { # php/fastcgi
        listen [2001:41D0:2:8673::1];
        listen 80;
        server_name img.italiansubs.net;
        access_log logs/img.access.log main;
        root /var/www/img.italiansubs.net/public_html;

        location / {
            index index.html index.htm index.php index.xml;
        }

        location /news2/data/ {
            expires 35d;
        }

        location ~ \.php$ {
            fastcgi_pass unix:/tmp/php-fpm.sock;
# fastcgi_pass 127.0.0.1:9000;
        }
    }

```

If I manually restart nginx via init script it works, but of course all  
the open connections are dropped, which is something I would like to  
avoid.

Thanks a lot,  
Andrea

Posted at Nginx Forum:

> **[Problem upgrading on the fly when ipv6 is used](https://forum.nginx.org/read.php?2,91799,91799#msg-91799)**
>
> Hi! I've always upgraded nginx on the fly following this guide: http://wiki.nginx.org/NginxCommandLine without problems. I recently added IPv6 support to nginx and now, when I need to upgrade it, it doesn't start the new instance when I send the USR2...

---

<div class="post-metadata">

**Author:** ![Usu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/85f322/32.png) [@Usu](https://www.ruby-forum.com/u/Usu)\
**Post date:** [May 31, 2010, 1:33am UTC](https://www.ruby-forum.com/t/problem-upgrading-on-the-fly-when-ipv6-is-used/189348/2 "2010-05-31T01:33:21Z")

</div>

Hello!

On Sat, May 29, 2010 at 03:23:54AM -0400, Usu wrote:

> I’ve always upgraded nginx on the fly following this guide:  
> [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxCommandLine) without problems.  
> I recently added IPv6 support to nginx and now, when I need to  
> upgrade it, it doesn’t start the new instance when I send the  
> USR2 signal to the master process, giving the following erros:
> 
> [code]  
> 2010/05/29 09:05:52 [notice] 21060#0: using inherited sockets from “14;15;”  
> 2010/05/29 09:05:52 [emerg] 21060#0: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already in use)  
> [emerg]: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already in use)

[…]

Attached patch should resolve this issue.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Usu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/85f322/32.png) [@Usu](https://www.ruby-forum.com/u/Usu)\
**Post date:** [May 31, 2010, 10:17am UTC](https://www.ruby-forum.com/t/problem-upgrading-on-the-fly-when-ipv6-is-used/189348/3 "2010-05-31T10:17:44Z")

</div>

Hello!

On Mon, May 31, 2010 at 03:57:28AM -0400, Usu wrote:

> Hello,
> 
> thanks for the help, I tried patching the 0.8.38 release but it’s giving me an error:
> 
> root@localhost:/usr/src/nginx-0.8.38# patch -p1 \< ipv6.diff  
> patching file src/core/ngx\_connection.c  
> Hunk #1 FAILED at 96.  
> 1 out of 1 hunk FAILED – saving rejects to file src/core/ngx\_connection.c.rej
> 
> And here’s the file generated:

[…]

> Am I doing something wrong?

It’s mailing list ↔ forum gateway which tried to interpret  
bbcodes and mungled patch. You may obtain correct one from here:

> **[Problem upgrading on the fly when ipv6 is used](http://mailman.nginx.org/pipermail/nginx/2010-May/020621.html)**

Maxim D.

---

<div class="post-metadata">

**Author:** ![Usu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/85f322/32.png) [@Usu](https://www.ruby-forum.com/u/Usu)\
**Post date:** [May 31, 2010, 1:54pm UTC](https://www.ruby-forum.com/t/problem-upgrading-on-the-fly-when-ipv6-is-used/189348/4 "2010-05-31T13:54:53Z")

</div>

Ok, it works like a charm thank you!  
Will it be fixed in the next release of nginx?

Posted at Nginx Forum:

> **[Re: Problem upgrading on the fly when ipv6 is used](https://forum.nginx.org/read.php?2,91799,92645#msg-92645)**
>
> Hi! I've always upgraded nginx on the fly following this guide: http://wiki.nginx.org/NginxCommandLine without problems. I recently added IPv6 support to nginx and now, when I need to upgrade it, it doesn't start the new instance when I send the USR2...

---

<div class="post-metadata">

**Author:** ![Usu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/85f322/32.png) [@Usu](https://www.ruby-forum.com/u/Usu)\
**Post date:** [May 31, 2010, 3:14pm UTC](https://www.ruby-forum.com/t/problem-upgrading-on-the-fly-when-ipv6-is-used/189348/5 "2010-05-31T15:14:29Z")

</div>

Hello!

On Mon, May 31, 2010 at 07:53:51AM -0400, Usu wrote:

> Ok, it works like a charm thank you!  
> Will it be fixed in the next release of nginx?

It’s up to Igor, but most likely it will be fixed.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Usu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/85f322/32.png) [@Usu](https://www.ruby-forum.com/u/Usu)\
**Post date:** [May 31, 2010, 4:42pm UTC](https://www.ruby-forum.com/t/problem-upgrading-on-the-fly-when-ipv6-is-used/189348/6 "2010-05-31T16:42:18Z")

</div>

On Mon, May 31, 2010 at 05:13:15PM +0400, Maxim D. wrote:

> Hello!
> 
> On Mon, May 31, 2010 at 07:53:51AM -0400, Usu wrote:
> 
> > Ok, it works like a charm thank you!  
> > Will it be fixed in the next release of nginx?
> 
> It’s up to Igor, but most likely it will be fixed.

Yes, I will include it in 0.8.39, thank you.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![Usu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/85f322/32.png) [@Usu](https://www.ruby-forum.com/u/Usu)\
**Post date:** [May 31, 2010, 9:58am UTC](https://www.ruby-forum.com/t/problem-upgrading-on-the-fly-when-ipv6-is-used/189348/7 "2010-05-31T09:58:25Z")

</div>

Hello,

thanks for the help, I tried patching the 0.8.38 release but it’s giving  
me an error:

root@localhost:/usr/src/nginx-0.8.38# patch -p1 \< ipv6.diff  
patching file src/core/ngx\_connection.c  
Hunk #1 FAILED at 96.  
1 out of 1 hunk FAILED – saving rejects to file  
src/core/ngx\_connection.c.rej

And here’s the file generated:

```auto
*************** ngx_set_inherited_sockets(ngx_cycle_t *c
***96,109****
      ls = cycle->listening.elts;
      for (i = 0; i < cycle->listening.nelts; i++) {

- /* AF_INET only */
-
- ls.sockaddr = ngx_palloc(cycle->pool, sizeof(struct 
sockaddr_in));
          if (ls.sockaddr == NULL) {
              return NGX_ERROR;
          }

- ls.socklen = sizeof(struct sockaddr_in);
          if (getsockname(ls.fd, ls.sockaddr, &ls.socklen) == -1) {
              ngx_log_error(NGX_LOG_CRIT, cycle->log, ngx_socket_errno,
                            "getsockname() of the inherited "
--- 96,107 ----
      ls = cycle->listening.elts;
      for (i = 0; i < cycle->listening.nelts; i++) {

+ ls.sockaddr = ngx_palloc(cycle->pool, NGX_SOCKADDRLEN);
          if (ls.sockaddr == NULL) {
              return NGX_ERROR;
          }

+ ls.socklen = NGX_SOCKADDRLEN;
          if (getsockname(ls.fd, ls.sockaddr, &ls.socklen) == -1) {
              ngx_log_error(NGX_LOG_CRIT, cycle->log, ngx_socket_errno,
                            "getsockname() of the inherited "
```

Am I doing something wrong?

Thanks,  
Andrea

Posted at Nginx Forum:

> **[Re: Problem upgrading on the fly when ipv6 is used](https://forum.nginx.org/read.php?2,91799,92579#msg-92579)**
>
> Hi! I've always upgraded nginx on the fly following this guide: http://wiki.nginx.org/NginxCommandLine without problems. I recently added IPv6 support to nginx and now, when I need to upgrade it, it doesn't start the new instance when I send the USR2...
