nginx does not start automatically, what have I done?

Maxim Dounin mdounin at mdounin.ru
Thu Feb 16 14:18:52 UTC 2023


Hello!

On Thu, Feb 16, 2023 at 02:48:23PM +0800, JK wrote:

>    Hello, it is my first time posting here, and I appreciate the
>    opportunity to share my experience with nginx.
> 
> 
>    Just to give you background, I am using a VPS from Racknerd, and I use
>    CWP (Control Web Panel), which is pretty similar to cPanel.
> 
> 
>    I tried to update the repo and use dnf upgrade -y, and what happened
>    was, after restarting the server, nginx did not start automatically.
> 
> 
>    Here is the log of nginx:
> 
> 
>    ● nginx.service - The nginx HTTP and reverse proxy server
>       Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled;
>    vendor preset: disabled)
>       Active: failed (Result: exit-code) since Wed 2023-02-15 17:29:03
>    EST; 7h ago
>      Process: 779 ExecStartPre=/usr/sbin/nginx -t (code=exited,
>    status=1/FAILURE)
>      Process: 776 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited,
>    status=0/SUCCESS)
>    Feb 15 17:29:02 racknerd-f5**** systemd[1]: Starting The nginx HTTP and
>    reverse proxy server...
>    Feb 15 17:29:02 racknerd-f5**** nginx[779]: nginx: the configuration
>    file /etc/nginx/nginx.conf syntax is ok
>    Feb 15 17:29:03 racknerd-f5**** nginx[779]: nginx: [emerg] bind() to
>    100.xx.xx.xx:80 failed (99: Cannot assign requested address)
>    Feb 15 17:29:03 racknerd-f5**** nginx[779]: nginx: configuration file
>    /etc/nginx/nginx.conf test failed
>    Feb 15 17:29:03 racknerd-f5**** systemd[1]: nginx.service: Control
>    process exited, code=exited status=1
>    Feb 15 17:29:03 racknerd-f5**** systemd[1]: nginx.service: Failed with
>    result 'exit-code'.
>    Feb 15 17:29:03 racknerd-f5**** systemd[1]: Failed to start The nginx
>    HTTP and reverse proxy server.
> 
> 
>    The solution is to manually start nginx after a minute or two.

The error message "bind() to 100.xx.xx.xx:80 failed (99: Cannot 
assign requested address)" suggests the IP address you are trying 
to use is not available when nginx starts.

Possible options to fix this include:

- Make sure nginx systemd service properly depends on the network 
  being available (After=/Wants= network-online.target is usually 
  good enough, though you may need to also enable proper wait 
  service, see [1]).

- Reconfigure nginx to listen on the wildcard address instead, so 
  it won't try to bind on IP addresses not yet available when it 
  starts.

Hope this helps.

[1] https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list