get local ip address ipv4 code example Example: get local ipv4 hostname = socket.gethostname() local_ip = socket.gethostbyname(hostname)