gaierror: [Errno 8] nodename nor servname provided, or not known
Question: Hello I am new to python , I am writing a code which generates dns requests

    
    
        from socket import error as socket_error
        import threading
        from random import randint
        from time import sleep
    
        def task(number):
           try :
              HOST = Random_website.random_website().rstrip() # fetches url
              PORT = 80              # The same port as used by the server
              s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    
              s.connect((HOST, PORT))
              print(str(number) +":"+HOST +"Connected")
           except socket_error as serr:
             if serr.errno != errno.ECONNREFUSED:
               # Not the error we are looking for, re-raise
                raise serr      
    
      thread_list = []
    
      for i in range(1, 100):    
        t = threading.Thread(target=task, args=(i,))
        thread_list.append(t)
    
      for thread in thread_list:
          thread.start()
    

Executing above code throws this error, can anyone help me out of this I am
pulling out my hair from one day

Thanks in advance


Answer: **Like this:**

    
    
    Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
    [GCC 4.8.2] on linux2
    Type "copyright", "credits" or "license()" for more information.
    >>> import socket
    >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    >>> s.connect(("www.google.com",80))
    >>> s.connect(("http://www.google.com",80))
    
    Traceback (most recent call last):
      File "<pyshell#3>", line 1, in <module>
        s.connect(("http://www.google.com",80))
      File "/usr/lib/python2.7/socket.py", line 224, in meth
        return getattr(self._sock,name)(*args)
    gaierror: [Errno -2] Name or service not known
    >>> 
    

**Socket not a`HTTP` connection !**

**Remove`HTTP://` tag before sending a request !**

EDIT:

    
    
    >>> import socket
    >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    >>> s.connect(("digan.net",80))
    >>> s.connect(("digan.net/hahaha/hihihi/etc",80))
    
    Traceback (most recent call last):
      File "<pyshell#8>", line 1, in <module>
        s.connect(("digan.net/hahaha/hihihi/etc",80))
      File "/usr/lib/python2.7/socket.py", line 224, in meth
        return getattr(self._sock,name)(*args)
    gaierror: [Errno -2] Name or service not known
    >>> 
    

**Socket can't send request to additional path. Only talk with server !**

