0

I have the code below which results in:

 File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed

The code is:

 import sys
    sys.path.append 
    ('C:/Users/xxxxx/source/packages')
    import paramiko
    import sys
    host = "sftp://sftp.xxxxx.com"
    port = 22
    transport = paramiko.Transport((host, port))
    password = "xxxx"
    username = "xxxxx"
    transport.connect(username,password)
    sftp = paramiko.SFTPClient.from_transport(transport)
    filepath = 'C:/Python36'
    localpath = '/'
    sftp.get(filepath, localpath)

The error line:

if type(sock) is tuple: # connect to the given (host, port) hostname, port = sock self.hostname = hostname reason = 'No suitable address family' addrinfos = socket.getaddrinfo( hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM

And the first error message is:

 line 317, in init hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM

Moreover, I have no idea on which path should I set (I have only sftp, username, password and port and that's enough for Mozilla)

Christopher Nuccio
  • 596
  • 1
  • 9
  • 21
Diegoctn
  • 55
  • 1
  • 10
  • 1
    Please paste a full traceback, so we know which line of your code actually caused the problem. Read the [mcve] page in the help for more. – abarnert Mar 26 '18 at 15:49
  • Anyway, the error is telling you that the attempt to look up the domain name `sftp.xxxxx.com` failed. (Presumably that’s an obfuscated name, so it’s the real name in your code that failed, of course.) Is there really a host named `sftp` in your domain? Can you look it up with `dig`, or just `ping` it and see if you get a name lookup error? – abarnert Mar 26 '18 at 15:53
  • Also, are you sure a complete URL is the right thing to pass to the Transport constructor? Usually APIs like that take just the domain name. – abarnert Mar 26 '18 at 15:54
  • Please edit the info into the question. Comments don’t preserve complex formatting, aren’t visible to people looking for answerable questions to help with, etc. – abarnert Mar 26 '18 at 16:09
  • Hi Abarnet, I tried with sftp:\\ and without and the result is the same – Diegoctn Mar 27 '18 at 07:19
  • Well, `sftp:\\` is _definitely_ wrong. And, at any rate, you still need to try resolving the domain name manually and report back what it says, as I asked you to yesterday. – abarnert Mar 27 '18 at 17:01

0 Answers0