Not a very descriptive error, is it?
bind(0.0.0.0) failed (22: Invalid argument) while connecting to upstream
Let me tell you, this is caused (or at least in the setup I was tasked with fixing it was) by proxy_bind
directive. In the case of the error above, it was set to 0.0.0.0
.
But why does it cause the error? Because the upstream is or resolves to an IPv6 address. And that’s incompatible with a connection coming from 0.0.0.0 (i.e., any IPv4 address available)! In most cases, you don’t actually need the proxy_bind
directive at all, so remove it, probably you just copy-pasted it anyway. ;·)
For more details, you might want to read this bugreport.
HEADS-UP! If you’re tempted to “just disable IPv6 altogether,” be aware that the world is shifting to IPv6-only. So disabling IPv4 altogether seems like the better option to me (in that case be sure to let me know, I’ll add your website to the list! :·)).
BTW, if you want to keep using nginx instead of Apache, I suggest switching to freenginx. Read more about it in its announcement.
Tagged with: nginx
Written: 2024-03-19