Cannot assign requested address

dom0 asked:

openssl req -new -x509 -days 8192 -newkey rsa:4096 -extensions v3_ca -config conf/caconfig.cnf -keyform PEM -keyout private/ -outform PEM -out certs/

I’m using nginx in conjunction with IPv6 without any issues for a while now, but when trying to deploy SSL it fails with bind() to [...]:443 failed (99: Cannot assign requested address)

nginx config (no server names etc.):

# Works like a charm
server {
        listen          80;
        listen          [2a03:4000:2:3c8:6e65:6f6b:6572:80]:80;
        return 301 https://$host$request_uri;

# Cannot assign requested address
server {
        listen          443 ssl;
        listen          [2a03:4000:2:3c8:6e65:6f6b:6572:443]:443 ssl;

Using IPv6 addresses with the last two octets being the port works like a charm with other services, too. No other service uses :443 or that address (verified via ip addr show not mentioning it).

My answer:

You can’t listen on an address that your server doesn’t actually have configured on one of its interfaces. And you said that that your server’s network interface isn’t configured for that address.

To resolve the problem, add that address to your network interface configuration.

You should also consider having nginx bind to any address, e.g. with listen [::]:443 ssl.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.