# 'sudo nginx -s reload' and 'nginx -t' started to need a minute to complete

**URL:** <https://www.ruby-forum.com/t/sudo-nginx-s-reload-and-nginx-t-started-to-need-a-minute-to-complete/200501>\
**Category:** NGINX\
**Created:** [December 13, 2010, 9:58pm UTC](https://www.ruby-forum.com/t/sudo-nginx-s-reload-and-nginx-t-started-to-need-a-minute-to-complete/200501 "2010-12-13T21:58:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 13, 2010, 9:58pm UTC](https://www.ruby-forum.com/t/sudo-nginx-s-reload-and-nginx-t-started-to-need-a-minute-to-complete/200501/1 "2010-12-13T21:58:22Z")

</div>

While using Ubuntu 10.10+Nginx0.9.3+php5-fpm 5.3.3-1ubuntu9.1:

Do you know of any reason for ‘sudo nginx -s reload’ and ‘nginx -t’  
suddenly start needing almost a minute to complete?

while using:  
server {  
listen [example.org:80](http://example.org:80);  
server\_name [www.example.org](http://www.example.org) .example.com 192.168.2.18;  
rewrite ^(.\*) [http://example.org$1](http://example.org$1) permanent;  
}  
server {  
listen [example.org:80](http://example.org:80) default\_server;  
server\_name [example.org](http://example.org);  
…/…

$ time sudo nginx -s reload  
real 0m0.354s  
user 0m0.336s  
sys 0m0.012s

after adding:  
server {  
listen [example.com:80](http://example.com:80);  
server\_name [www.example.com](http://www.example.com);  
rewrite ^(.\*) [http://example.com$1](http://example.com$1) permanent;  
}  
server {  
listen [example.com:80](http://example.com:80);  
server\_name [example.com](http://example.com);  
…/…

$ time sudo nginx -s reload  
real 0m56.152s  
user 0m0.077s  
sys 0m0.016s

$ nginx -V  
nginx: nginx version: nginx/0.9.3  
nginx: TLS SNI support enabled  
nginx: configure arguments: --conf-path=/etc/nginx/nginx.conf  
–error-log-path=/var/log/nginx/error.log  
–http-client-body-temp-path=/var/lib/nginx/body  
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi  
–http-log-path=/var/log/nginx/access.log  
–http-proxy-temp-path=/var/lib/nginx/proxy  
–lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid  
–prefix= --with-http\_ssl\_module --without-http\_limit\_req\_module  
–without-mail\_pop3\_module --without-mail\_smtp\_module  
–without-mail\_imap\_module --without-http\_split\_clients\_module  
–without-http\_uwsgi\_module --without-http\_scgi\_module  
–without-http-cache

$ cat /etc/hosts  
127.0.0.1 localhost  
192.168.2.17 [mail.example.com](http://mail.example.com) [example.com](http://example.com) [www.example.com](http://www.example.com) [example.org](http://example.org)  
[www.example.org](http://www.example.org)  
192.168.2.18 mail.example.tld example.tld www.example.tld

cat /etc/network/interfaces  
auto lo  
iface lo inet loopback

# Load IPTABLES firewall rules

pre-up iptables-restore \< /etc/iptables.up.rules  
auto eth0  
#iface eth0 inet dhcp  
iface eth0 inet static  
address 192.168.2.17  
network 192.168.2.0  
netmask 255.255.255.0  
broadcast 192.168.2.255  
gateway 192.168.2.1  
auto eth0:0  
iface eth0:0 inet static  
address 192.168.2.18  
network 192.168.2.0  
netmask 255.255.255.0  
broadcast 192.168.2.255  
gateway 192.168.2.1

Thank you.

M.

---

<div class="post-metadata">

**Author:** ![larios](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bc79bd/32.png) [@larios](https://www.ruby-forum.com/u/larios)\
**Post date:** [December 13, 2010, 11:29pm UTC](https://www.ruby-forum.com/t/sudo-nginx-s-reload-and-nginx-t-started-to-need-a-minute-to-complete/200501/2 "2010-12-13T23:29:38Z")

</div>

Hello!

On Mon, Dec 13, 2010 at 08:57:04PM +0000, Mark A. wrote:

> rewrite ^(.\*) [http://example.org$1](http://example.org$1) permanent;
> 
> …/…
> 
> $ time sudo nginx -s reload  
> real 0m56.152s  
> user 0m0.077s  
> sys 0m0.016s

Most likely reason is [example.com](http://example.com) having problems with DNS  
servers.

While reading/parsing configuration (which is done by both nginx  
-t and nginx -s reload) nginx will try to resolve names in listen  
directive. If it takes a while you’ll see large delays, exactly  
as in your case.

Note that host names in proxy\_pass directive are resolved as well,  
so names there may delay loading as well.

[…]

> $ cat /etc/hosts  
> 127.0.0.1 localhost  
> 192.168.2.17 [mail.example.com](http://mail.example.com) [example.com](http://example.com) [www.example.com](http://www.example.com) [example.org](http://example.org)  
> [www.example.org](http://www.example.org)  
> 192.168.2.18 mail.example.tld example.tld www.example.tld

You may want to check spelling for “[example.com](http://example.com)” here and in nginx  
config.

Maxim D.

---

<div class="post-metadata">

**Author:** ![larios](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bc79bd/32.png) [@larios](https://www.ruby-forum.com/u/larios)\
**Post date:** [December 14, 2010, 10:59am UTC](https://www.ruby-forum.com/t/sudo-nginx-s-reload-and-nginx-t-started-to-need-a-minute-to-complete/200501/3 "2010-12-14T10:59:19Z")

</div>

On Tue, 14 Dec 2010 01:28:14 +0300, Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Most likely reason is [example.com](http://example.com) having problems with DNS  
> servers.

You were right, it was a DNS problem.

> While reading/parsing configuration (which is done by both nginx  
> -t and nginx -s reload) nginx will try to resolve names in listen  
> directive.

I did not know that while testing nginx tries to resolve names (both in  
listen and in proxy\_pass).  
It another a useful feature of nginx.  
Knowing that would have made me think a DNS problem.

Thank you very much Maxim.

M.
