socket.gaierror: [Errno 8] nodename nor servname provided, or not known
13,625
Solution 1
Remove the quotes in your configuration file
[main]
enable = 1
server = my.ftp.address
user_name = some_user_name
password = some_password
Solution 2
I had the same socket.gaierror
being thrown.
This caused the error:
companies_list = ['https://www.coinbase.com', 'https://www.glassdoor.com']
Removing the protocol stopped the error:
companies_list = ['www.coinbase.com', 'www.glassdoor.com']
Related videos on Youtube
Author by
St4rb0y
Updated on June 04, 2022Comments
-
St4rb0y almost 2 years
I'm trying to connect to my ftp server with the following Python script on a Mac running OS X Yosemite (10.10.5):
from ftplib import FTP import ConfigParser config_file = "ftp.config" config = ConfigParser.ConfigParser() try: config.read(config_file) except: raise Exception("Failed reading {} file.").format(config_file) server_address = config.get("main", "server") user_name = config.get("main", "user_name") password = config.get("main", "password") ftp = FTP(server_address) ftp.login(user_name, password) print "Logging in as '{}'".format(user_name)
The script gets the server information from the file "ftp.config" with the following content:
[main] enable = 1 server = "my.ftp.address" user_name = "some_user_name" password = "some_password"
When I run the script, I get the following error:
Traceback (most recent call last): File "ftp2.py", line 34, in <module> ftp = FTP(server_address) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ftplib.py", line 120, in __init__ self.connect(host) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ftplib.py", line 135, in connect self.sock = socket.create_connection((self.host, self.port), self.timeout) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 557, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): socket.gaierror: [Errno 8] nodename nor servname provided, or not known
I have no idea why the error occurs. I've tried to
.split()
the strings from the ".config" file, in order to remove superfluous lines, but this doesn't seem to help.Any ideas, guys?
Thanks.