On this page
socket.gaierror
Prev: socket.fromfd | Up: socket | Next: socket.getaddrinfo
Rel: socket.AddressFamily, socket.close, socket.create_connection, socket.create_server
Ref: docs.python.org โ socket.gaierror
Tags: #public #python3 #stdlib #socket
Import
import socket
from socket import gaierror
Signature & Overview
socket.gaierror(...)
socket.gaierror class.
Methods & Attributes
gaierror.add_note(self, note, /)โ Add a note to the exceptiongaierror.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
import socket
try:
socket.getaddrinfo("invalid.invalid.example", 80)
except socket.gaierror as exc:
assert isinstance(exc, OSError)
Gotchas
- DNS / address-resolution error (
getaddrinfoerror): Subclass ofOSError; catch it separately fromConnectionRefusedErrorwhen reporting network diagnostics.
REPL Inspect
from socket import gaierror
help(gaierror)
Linked from
Related notes
- tuts/python3/stdlib_module/socket/fromfd Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/getaddrinfo Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/AddressFamily Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/close Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/create_connection Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/create_server Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/socket Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/socket/dup shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/error shared tags: #socket, #stdlib