nginx won't start on boot - ipv6 issues?

Discussion in 'General' started by breakaway, Mar 30, 2019.

  1. breakaway

    breakaway Member

    I've got a server with a Single IPv4 and a Single IPv6 address. I have the same IPv6 address assigned to 4 or 5 different sites.

    Whenever I reboot the box, nginx won't start. I have to rm all the 100-* symlinks from sites-enabled, then start nginx, then go to the website config and change something. From there on out it seems to work fine.

    In its failed state, this is what I'll see after the reboot:

    Code:
    # service nginx status
    ● nginx.service - A high performance web server and a reverse proxy server
       Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
       Active: failed (Result: exit-code) since Sat 2019-03-30 13:16:59 NZDT; 1min 40s ago
         Docs: man:nginx(8)
      Process: 593 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
    
    Mar 30 13:16:59 hosting systemd[1]: Starting A high performance web server and a reverse proxy server...
    Mar 30 13:16:59 hosting nginx[593]: nginx: [emerg] bind() to [2400:xxxx:xxxx:xxxx::8]:443 failed (99: Cannot assign requested address)
    Mar 30 13:16:59 hosting nginx[593]: nginx: configuration file /etc/nginx/nginx.conf test failed
    Mar 30 13:16:59 hosting systemd[1]: nginx.service: Control process exited, code=exited status=1
    Mar 30 13:16:59 hosting systemd[1]: Failed to start A high performance web server and a reverse proxy server.
    Mar 30 13:16:59 hosting systemd[1]: nginx.service: Unit entered failed state.
    Mar 30 13:16:59 hosting systemd[1]: nginx.service: Failed with result 'exit-code'.
    It says that the nginx.conf test has failed, but when i do a nginx -t it says everyhting is good:

    Code:
    # nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    If I do a

    Code:
    service nginx restart
    Then the system is fine also. This only seems to be an issue on reboots.

    I added 5 more IPv6 addresses to my system, then assigned each site a unique IPv6 address, rebooted. STILL getting the same behaviour.

    What gives?
     
  2. breakaway

    breakaway Member

    Bump - anyone?

    I have discovered through trial and error that this appears to be some sort of race condition issue. When the server is rebooted, the error says that

    Code:
    Mar 30 13:16:59 hosting nginx[593]: nginx: [emerg] bind() to [2400:xxxx:xxxx:xxxx::8]:443 failed (99: Cannot assign requested address
    However, if I simply SSH into the server aftre boot then issue a
    Code:
    service nginx restart
    on the shell, everything springs into life.

    "Cannot assign required address" suggest that there is something wrong with the network - could it be that the interface isn't up when nginx tries to start thereby causing this error?
     
  3. florian030

    florian030 ISPConfig Developer ISPConfig Developer

    you can try
    Code:
    echo "net.ipv6.ip_nonlocal_bind = 1" >> /etc/sysctl.conf
     
    ktownmods likes this.
  4. breakaway

    breakaway Member

    That worked, thanks!
     

Share This Page