I was using nginx as a reverse proxy for a webapp and noticed some requests intermittently failed with a 500 error.
For instance, the following request always failed at first page load :
http://localhost/get_library/ 500 Internal Server Error 2ms
But subsequent requests worked perfectly :
http://localhost/get_library/ 200 OK 18ms
The nginx error log was the following :
[alert] 13131#0: *39 socket() failed (97: Address family not supported by protocol) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /get_library/ HTTP/1.1", upstream: "http://[::1]:8080/get_library/", host: "localhost", referrer: "http://localhost/"
The part that got my attention is
http://[::1]:8080/get_library/ wich seems
to indicate that
localhost is resolved to
::1. As you probably know, it is localhost in ipv6.
As the ipv6 stack is disabled on my machine, I just changed my nginx conf from :
And it solved the problem !