how to get the ip of localhost code example Example: get local ip hostname = socket.gethostname() local_ip = socket.gethostbyname(hostname)