Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/snowflake/connector/auth/webbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,19 @@ def prepare(
socket_connection.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)

try:
hostname = os.getenv("SF_AUTH_SOCKET_ADDR", "localhost")
try:
socket_connection.bind(
(
os.getenv("SF_AUTH_SOCKET_ADDR", "localhost"),
hostname,
int(os.getenv("SF_AUTH_SOCKET_PORT", 0)),
)
)
except socket.gaierror as ex:
if ex.args[0] == socket.EAI_NONAME:
raise OperationalError(
msg="localhost is not found. Ensure /etc/hosts has "
"localhost entry.",
msg=f"{hostname} is not found. Ensure /etc/hosts has "
f"{hostname} entry.",
errno=ER_NO_HOSTNAME_FOUND,
)
else:
Expand Down
Loading