Hi Guys,
I really need your help. I met a strange issue from nginx error log as below:
Code:
2017/10/18 15:19:48 [crit] 41689#0: *23414459 connect() to 127.0.0.1:1234 failed (99: Cannot assign requested address) while connecting to upstream, client: 10.0.0.1, server: example.com, request: "GET / HTTP/1.0", upstream: "http://127.0.0.1:1234/", host: "www.example.com"
So from the error log, nginx is reporting it can not assign a local port when try to connect to upstream 127.0.0.1:1234.
Here is the kernel parameter associated with the local port:
Code:
net.ipv4.ip_local_port_range=2048 65000
net.ipv4.ip_local_reserved_ports=1024-10000
the config means I could use 55000 local ports.
I find that this problem emerges at the time when the local ports for all ips used up, check below:
Code:
Wed Oct 18 15:19:48 CST 2017 <- same time as the nginx log above
55000 <- number of local ports used for all ips
22.10.177.5 52023 <- number of local ports used for public ip
127.0.0.1 4881 <- number of local ports used for 127.0.0.1
So my question is why nginx thrown that error since only 4881 local ports used for 127.0.0.1?
Other tests tried when whole local ports used up (for all ip):
Code:
:~# telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
^]
telnet> Connection closed.
:~# telnet 10.0.0.2 1234
Trying 10.0.0.2...
Connected to 10.0.0.2.
Escape character is '^]'.
^]
telnet> Connection closed.
:~# telnet 127.0.0.1 1234
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Cannot assign requested address
telnet failed as well, means it's not an issue of nginx.
system info:
Code:
Linux kernel: 4.9.0-040900-generic
distro: Ubuntu 14.04
Please help. Thanks in advance.