The Chillidog Software Blog

The ramblings of a developer

Fix for 'Name or service not known' error with boto

After searching and searching, a small post found here lead me the answer for fixing my connection issues with boto.

Traceback (most recent call last):
File "./my-python-script.py", line 111, in <module>
bucket = conn.create_bucket(bucket_name)
File "/usr/lib/python2.6/site-packages/boto/s3/connection.py", line 434, in create_bucket
data=data)
File "/usr/lib/python2.6/site-packages/boto/s3/connection.py", line 470, in make_request
override_num_retries=override_num_retries)
File "/usr/lib/python2.6/site-packages/boto/connection.py", line 913, in make_request
return self._mexe(http_request, sender, override_num_retries)
File "/usr/lib/python2.6/site-packages/boto/connection.py", line 859, in _mexe
raise e
socket.gaierror: [Errno -2] Name or service not known

In code, the solution was as simple as specifying the calling format when you make your initial connection to S3. I hope this helps others as well.

from boto.s3.connection import S3Connection
calling_format=boto.s3.connection.OrdinaryCallingFormat()
conn = S3Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, calling_format=calling_format)