Sytem Error: nginx restart failed

Hello @lamnian,

Try to rise limits used by master nginx process started with systemd.

As root:

systemctl edit nginx.service

This will open the file /etc/systemd/system/nginx.service.d/override.conf so you need to add two lines between the comments, as shown below:

### Editing /etc/systemd/system/nginx.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file

[Service]
LimitNOFILE=8192

### Lines below this comment will be discarded

### /etc/systemd/system/nginx.service

Save the file and restart nginx

systemctl restart nginx.service

Check again the limits and also nginx:

cat /proc/$(cat /var/run/nginx.pid)/limits | grep -i 'Max open files'

nginx -t

Cheers,
sahsanu

If you use Proxmox you need to update this value in the host config aswell

Done that also…

### Editing /etc/systemd/system/nginx.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file

[Service]
LimitNOFILE=500000

### Lines below this comment will be discarded

### /etc/systemd/system/nginx.service
# [Unit]
# Description=nginx - high performance web server
# Documentation=https://nginx.org/en/docs/
# After=network-online.target remote-fs.target nss-lookup.target
# Wants=network-online.target
# 
# [Service]
# Type=forking
# PIDFile=/var/run/nginx.pid
# ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
# ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)"
# ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)"
# LimitNOFILE=500000
# 
# [Install]
# WantedBy=multi-user.target

And I get

Max open files            500000               500000               files  

and still

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] open() "/var/log/nginx/domains/webmail.mydomain.cx.log" failed (24: Too many open files)
nginx: configuration file /etc/nginx/nginx.conf test failed

Thanx

What’s the value of directive worker_rlimit_nofile?

grep -ri worker_rlimit_nofile /etc/nginx/

Also, show the output of this command to view the number of files used per process:

lsof | awk '{print $1}' | sort | uniq -c | sort -nr | head -25

/etc/nginx/nginx.conf.vst.back:worker_rlimit_nofile    65535;
/etc/nginx/nginx.conf:worker_rlimit_nofile 100000;
 242464 mariadbd
  91866 apache2
  11243 nginx
   6682 named
   2900 php-fpm7.
   1866 imap
   1697 imap-logi
    765 fail2ban-
    572 php-fpm8.
    558 php-fpm5.
    252 dovecot
    205 miniserv.
    172 cron
    160 sshd
    152 systemd
    140 rsyslogd
    132 stats
    129 clamd
    126 auth
    112 unattende
    112 exim4
    105 spamd\x20
     84 wget
     83 config
     83 anvil

Edit /etc/security/limits.conf and add these two lines:

root            hard    nofile           500000
root            soft    nofile           500000

Maybe you could add also the limits for nginx and/or www-data (I don’t know what is your system)

nginx            hard    nofile           500000
nginx            soft    nofile           500000
www-data         hard    nofile           500000
www-data         soft    nofile           500000

You should logoff from your session and connect again and then restart nginx, or better, reboot the server.

If this doesn’t work… I’m running out of ideas :frowning:

So I added to /etc/security/limits.conf

root hard nofile 50000
root soft nofile 50000
www-data hard nofile 50000
www-data soft nofile 50000
nginx hard nofile 50000
nginx soft nofile 50000

reboot and nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

But :frowning:

Nginx -t doesn’t check for open files it only happens during reload / restart ngin

How many active domains are on the server?

nginx -t also checks that it can access auxiliary files like log files so the error before raising the limits :wink:

Regarding the other error… I’ve no idea :frowning:

Yes but never fails on max open files…

There are about 60 Domains

in /var/log/hestiadebug.log we have the following error

[ 2023-08-06 19:47:54 | nginx | PROXY ]
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] open() "/var/log/nginx/domains/webmail.mydomain.cx.log" failed (24: Too many open files)
nginx: configuration file /etc/nginx/nginx.conf test failed

is there another user accusing when I edit a domain in hestia?

No. I assume you are using a VPS?

It’s a dedicated server.

Does anyone know what is the script that is used to disable a user from the panel. That is when I get the error.

Do you mean suspend a user?

If you mean suspend a user, the command is:

v-suspend-user HereTheUserName yes

The last yes is to restart the services.

No Remove Delete…

v-delete-user HereTheUserName yes

This will remove the user and all the web domains, dbs, mails, etc for that user so take care.

What is the difference between the v-suspend-user HereTheUserName yes and pressing pause button on in the panel.

v-suspend-user works, but if I do it thought the web panell I get the Nginx error…