1

I host an nginx web Server with an configured reverse proxy. I needed to renew some certificates. I had faulty configs in some configs of some domains. After fixing them nginx cant start anymore and I cant get anything of the error. I googled so much, nothing runs on port 80 except nginx. And I don't understand the empty server name. Which server name?

edit: it seems I fixed the server_name "" warning. But that's sadly not the solution to the problem. Systemctl status:

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)

sudo grep -r server_name /etc/nginx* output:

/etc/nginx/sites-enabled/pitlivesforever.conf:   server_name pitlivesforever.de;

/etc/nginx/sites-enabled/pitlivesforever.conf:   server_name pitlivesforever.de;
/etc/nginx/sites-enabled/calmingsurround.conf:   server_name calmingsurround.de;

/etc/nginx/sites-enabled/calmingsurround.conf:   server_name calmingsurround.de;
/etc/nginx/sites-enabled/walrussi.conf:   server_name walrussi.com;
/etc/nginx/sites-enabled/walrussi.conf:   server_name walrussi.com;
/etc/nginx/sites-enabled/onlyoffice.walrussi.conf:    server_name onlyoffice.walrussi.com;
/etc/nginx/sites-enabled/onlyoffice.walrussi.conf:    return 301 https://$server_name$request_uri;
/etc/nginx/sites-enabled/onlyoffice.walrussi.conf:    server_name onlyoffice.walrussi.com;
/etc/nginx/sites-enabled/bitwarden.walrussi.com:    server_name bitwarden.walrussi.com; #Change this to your domain name
/etc/nginx/sites-enabled/bitwarden.walrussi.com:  server_name bitwarden.walrussi.com; #Change this to your domain name
/etc/nginx/sites-enabled/wiki.walrussi.com.conf:    server_name wiki.walrussi.com;
/etc/nginx/sites-enabled/wiki.walrussi.com.conf:    return 301 https://$server_name$request_uri;
/etc/nginx/sites-enabled/wiki.walrussi.com.conf:    server_name wiki.walrussi.com;
/etc/nginx/sites-enabled/nextcloud.conf:   server_name nextcloud.walrussi.com;          
/etc/nginx/sites-enabled/nextcloud.conf:  return 301 https://$server_name$request_uri;
/etc/nginx/sites-enabled/nextcloud.conf:    server_name nextcloud.walrussi.com;
/etc/nginx/sites-enabled/dyndns.conf:    server_name libellulanas.lohse.de;
/etc/nginx/sites-enabled/dyndns.conf:    return 301 https://$server_name$request_uri;
/etc/nginx/sites-enabled/dyndns.conf:    server_name libellulanas.lohse.de;
/etc/nginx/scgi_params:scgi_param  SERVER_NAME        $server_name;
/etc/nginx/nginx.conf.old:  # server_names_hash_bucket_size 64;
/etc/nginx/nginx.conf.old:  # server_name_in_redirect off;
/etc/nginx/nginx.conf:  # server_names_hash_bucket_size 64;
/etc/nginx/nginx.conf:  # server_name_in_redirect off;
/etc/nginx/sites-available/default:        server_name _;
/etc/nginx/sites-available/default:#       server_name example.com;
/etc/nginx/uwsgi_params:uwsgi_param  SERVER_NAME        $server_name;
/etc/nginx/fastcgi.conf:fastcgi_param  SERVER_NAME        $server_name;
/etc/nginx/fastcgi_params:fastcgi_param  SERVER_NAME        $server_name;

Here the error:

2023/06/24 13:09:12 [warn] 4027610#4027610: conflicting server name "" on 0.0.0.0:80, ignored
2023/06/24 13:09:12 [warn] 4027610#4027610: conflicting server name "" on 0.0.0.0:80, ignored
2023/06/24 13:09:12 [warn] 4027611#4027611: conflicting server name "" on 0.0.0.0:80, ignored
2023/06/24 13:09:12 [warn] 4027611#4027611: conflicting server name "" on 0.0.0.0:80, ignored
2023/06/24 13:09:12 [emerg] 4027611#4027611: bind() to 0.0.0.0:80 failed (98: Unknown error)
2023/06/24 13:09:12 [emerg] 4027611#4027611: bind() to 0.0.0.0:80 failed (98: Unknown error)
2023/06/24 13:09:12 [emerg] 4027611#4027611: bind() to 0.0.0.0:80 failed (98: Unknown error)
2023/06/24 13:09:12 [emerg] 4027611#4027611: bind() to 0.0.0.0:80 failed (98: Unknown error)
2023/06/24 13:09:12 [emerg] 4027611#4027611: bind() to 0.0.0.0:80 failed (98: Unknown error)
2023/06/24 13:09:12 [emerg] 4027611#4027611: still could not bind()


sudo nginx -t:

nginx: [warn] conflicting server name "" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "" on 0.0.0.0:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

systemctl status ngingx.service:

× 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 2023-06-24 13:09:15 UTC; 9min ago
       Docs: man:nginx(8)
    Process: 4027610 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 4027611 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
        CPU: 82ms

netstat -tulpn | grep --color :80:

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      3366/nginx: master  
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      1916/docker-proxy   

I hope I just oversee some empty (?!) config but I can't find it. Thanks for your help! I tried to create "default" domain config if maybe nginx is missing a default? Upgraded the System. Killed all nginx processes and tried to start it again.

  • 1
    In the nginx configs you must have.a server declaration. The error shows that you have no server name configured between the doublquote is not a single character. In nginx the _ underscore can be used as a catchall for the servername, you can also explicitly list your domain names eh. abc.com www.abc.com – sleepyhead Jun 24 '23 at 13:47
  • You mean the config file "nginx.conf "? In all other domain configs I configured a server_name. – FreddyWalrus Jun 24 '23 at 13:59
  • 1
    **"I hope I just oversee some empty (?!) config but I can't find it."** Please explain why you cannot find it. It should be here: `/etc/nginx/nginx.conf` (like `nginx -t` told you) – Luuk Jun 24 '23 at 14:01
  • Okay I didnt mean I cant find the nginx.conf. But I didnt change anything in it. – FreddyWalrus Jun 24 '23 at 14:05
  • 1
    Can you add the output of this to your question?: `sudo grep -r server_name /etc/nginx*` – Luuk Jun 24 '23 at 14:12
  • 1
    "Killed all nginx processes", No, please do: `systemctl stop nginx`. – Luuk Jun 24 '23 at 14:15
  • @Luuk Done. Yes Ive done that too but also killed all processes just in case. – FreddyWalrus Jun 24 '23 at 14:18
  • 1
    you question seems to be a duplicate of: [Nginx will not start (Address already in use)](https://stackoverflow.com/questions/42303401/nginx-will-not-start-address-already-in-use), but that should have been shown in the output of your `netstat...` command. I am afraid I am out of options... – Luuk Jun 24 '23 at 14:39
  • 1
    https://stackoverflow.com/q/14972792/2955337 – sleepyhead Jun 24 '23 at 15:37
  • 1
    I also think the nginx tries to bind again to port 80, you could remove the default if it's there. But otherwise I'd rebuild the configs one domain at a time until you hit problems, you can use reload to add configs while the other sites remain up. From the above I can't spot a fault, -t also doesn't fail the configs, but error 97 points to starting the nginx Daemon twice. (Two listen directives?) – sleepyhead Jun 24 '23 at 15:41
  • @sleepyhead Thank you. My style of doing things was the problem. I moved all of the domain configs and then it worked and then I edited one after another. At least we got all sorted out haha. :) – FreddyWalrus Jun 24 '23 at 16:19
  • We'll done, mystery solved. nginx is very powerful, but not so forgiving in configuration – sleepyhead Jun 24 '23 at 19:07

1 Answers1

0

@sleepyhead

I'd rebuild the configs one domain at a time until you hit problems, you can use reload to add configs while the other sites remain up. From the above I can't spot a fault

That worked. Haha. I was the fault.