From 668e4a1dfbea398410f86d803fadc733f4e5ed26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Tue, 16 Mar 2021 10:21:37 +0000 Subject: [PATCH] Closes #1614: Added extra logging suggesting solution when 'bind()' fails due to 'EADDRNOTAVAIL' --- lib/network.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/network.cpp b/lib/network.cpp index adbba27c3..63dc1e575 100644 --- a/lib/network.cpp +++ b/lib/network.cpp @@ -51,6 +51,13 @@ int listen_on_port(char *ip, uint16_t port, int backlog, bool reuseport) { if (bind(sd, next->ai_addr, next->ai_addrlen) == -1) { //if (errno != EADDRINUSE) { proxy_error("bind(): %s\n", strerror(errno)); + // in case of 'EADDRNOTAVAIL' suggest a solution to user. See #1614. + if (errno == EADDRNOTAVAIL) { + proxy_info( + "Trying to 'bind()' failed due to 'EADDRNOTAVAIL'. If trying to bind to a " + "non-local IP address, make sure 'net.ipv4.ip_nonlocal_bind' is set to '1'\n" + ); + } close(sd); freeaddrinfo(ai); return -1;