Solved Nginx cannot be started.

kariha

Verified User
Joined
Sep 12, 2011
Messages
46
I did a new server setup. Now the server is set up with apache as directadmin does automatic installation. Later, I wanted to install nginx_apache, but nginx cannot be started.

The error I'm getting is this: nginx: [emerg] bind() to [::1]:80 failed (99: Cannot assign requested address)

This is the full dump I get when I enter the command "systemctl status nginx.service":
Aug 04 00:13:54 sun.kariha.net nginx[24375]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Aug 04 00:13:54 sun.kariha.net nginx[24375]: nginx: [emerg] bind() to [::1]:80 failed (99: Cannot assign requested address)
Aug 04 00:13:54 sun.kariha.net nginx[24375]: nginx: configuration file /etc/nginx/nginx.conf test failed
Aug 04 00:13:54 sun.kariha.net systemd[1]: nginx.service: Control process exited, code=exited status=1
Aug 04 00:13:54 sun.kariha.net systemd[1]: nginx.service: Failed with result 'exit-code'.
Aug 04 00:13:54 sun.kariha.net systemd[1]: Failed to start The nginx HTTP and reverse proxy server.

Maybe it helps. Nginx logs also have errors like:
23/08/04 00:19:02 [warn] 38349#0: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/nginx-vhosts.conf:40
2023/08/04 00:19:02 [warn] 38349#0: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/nginx-vhosts.conf:41
2023/08/04 00:19:02 [warn] 38349#0: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/nginx-vhosts.conf:42
2023/08/04 00:19:02 [warn] 38349#0: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /usr/local/directadmin/data/users/eswabrct/ nginx.conf:54

System works when i revert to apache. Websites are not working when I install nginx_apache.

Solutions I've tried:
Since CSF was installed with apache, maybe it was blocking the ports, I removed the CSF.

The following line in /etc/nginx/nginx-vhosts.conf
I replaced "listen [::1]:80" with: "listen *:80;"

I added the following line in /etc/sysctl.conf
net.ipv4.ip_nonlocal_bind = 1

Additional info: The server has ipv6 support. Delivered with the server. But I don't need ipv6

Thanks in advance for your help.
 
Hello,

You might disable IPv6 in DirectAdmin settings. Run as root:

Code:
da set ipv6 0 restart

for this and then reinstall nginx.
 
Back
Top