diff --git a/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc b/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc index 8c2745c02b2..ed2321b2971 100644 --- a/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +++ b/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc @@ -25,6 +25,8 @@ #include "absl/cleanup/cleanup.h" #include "absl/status/status.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_replace.h" #include #include @@ -44,8 +46,6 @@ #include // IWYU pragma: keep #include // IWYU pragma: keep #include // IWYU pragma: keep - -#include "absl/strings/str_cat.h" #endif namespace grpc_event_engine { @@ -176,8 +176,16 @@ absl::Status PrepareSocket(const PosixTcpOptions& options, GRPC_FD_SERVER_LISTENER_USAGE, options)); if (bind(fd, socket.addr.address(), socket.addr.size()) < 0) { + auto sockaddr_str = ResolvedAddressToString(socket.addr); + if (!sockaddr_str.ok()) { + gpr_log(GPR_ERROR, "Could not convert sockaddr to string: %s", + sockaddr_str.status().ToString().c_str()); + sockaddr_str = ""; + } + sockaddr_str = absl::StrReplaceAll(*sockaddr_str, {{"\0", "@"}}); return absl::FailedPreconditionError( - absl::StrCat("Error in bind: ", std::strerror(errno))); + absl::StrCat("Error in bind for address '", *sockaddr_str, + "': ", std::strerror(errno))); } if (listen(fd, GetMaxAcceptQueueSize()) < 0) {