Nginx cannot bind to IPv6 interface on Plesk with error: Cannot assign requested

Started by mahesh, Dec 18, 2024, 06:27 AM

Previous topic - Next topic

mahesh

Question
Nginx cannot bind to IPv6 interface on Plesk with error: Cannot assign requested address
Symptoms
  • Error in Plesk UI:
New configuration files for the Apache web server were not created due to the errors in configuration templates: nginx: [emerg] bind() to 2001:db8:f61:a1ff:0:0:0:80:443 failed (99: Cannot assign requested address) nginx: configuration file /etc/nginx/nginx.conf test failed. Detailed error descriptions were sent to you by email. To fix the issue, follow the instructions described in KB: https://support.plesk.com/hc/articles/213933865 Please resolve the issues and click here to generate broken configuration files once again or here to generate all configuration files. See the details in Configuration Troubleshooter
  • Error in /var/log/nginx/error.log:
[emerg] 290143#0: bind() to [2001:db8:f61:a1ff:0:0:0:80]:443 failed (99: Cannot assign requested address)
[emerg] 290210#0: bind() to [2001:db8:f61:a1ff:0:0:0:80]:443 failed (99: Cannot assign requested address)

Cause
Nginx configuration tests are done before the IPv6 address is fully added to the system.

Resolution
Allow daemons to bind to non-existing IPv6 network interfaces to help pass the Nginx configuration test with the next steps:

1. Connect to the server via SSH

2. Add the following string to the bottom of the /etc/sysctl.conf file:

net.ipv6.ip_nonlocal_bind = 1
3.  Restart the nginx service:

#systemctl restart nginx