title: socket.gaierror: [Errno 8] codename nor servname provided, or not known
body: <p>This is a part of a program that worked fine until I've changed the computer name,
  hostname, localhostname (using sudo scutil --set...). it seems as if it has
  something to do with the environment?  Python 3.10.1 on MacBook Pro. Please help.</p>
  <pre><code>Traceback (most recent call last):
  get_sys_info(&quot;8.8.8.8&quot;)
  line 85, in get_sys_info
  IPAddress = socket.gethostbyname(hostname)
  socket.gaierror: [Errno 8] nodename nor servname provided, or not known
  
  
  def network_on(host_data,port_data,timeout_data):
      host = host_data
      port = port_data
      timeout = timeout_data
      import socket
      try:
          socket.setdefaulttimeout(timeout)
          socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host,port))
          return True
      except socket.error as ex:
          print(ex,'\n')
          return False
  
  
  def get_sys_info(host):
      import platform
      import subprocess
      import socket
      subprocess_output = []
      network_name = []
      hostname = socket.gethostname()
      IPAddress = socket.gethostbyname(hostname)
      s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
      print(&quot;You are connected to the internet”,’\n')
      print(“Checking the system......&quot;,'\n') 
      s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
      s.connect”8.8.8.8”,8))   
      Local_Router_IPAddr = s.getsockname()[0]
      print(“Python ver.:”:,platform.python_version(), ' ',&quot;Machine:&quot;,platform.machine(),
          ' ',&quot;System:&quot;,platform.system(), ' ',&quot;Platform:&quot;,platform.platform(),'\n')
      print(&quot;Hostname:&quot;,hostname,' ', &quot;Local Router IP Address:&quot;,\
            Local_Router_IPAddr,' ',&quot;IP Address:&quot;,IPAddress,'\n')
  </code></pre>