The ‘localhost’ name to IP resolution may take an exorbitant amount of time… depending on the OS configuration and type, routing tables, IPv6 vs IPv4 preference, etc. Just avoid this by using the explicit loopback IP ‘127.0.0.1’ instead of the string ‘localhost’. I’ve seen the Python request library take up to 2 seconds per request, which is spent resolving ‘localhost’.