AWS DynamoDB Python Connection Error
<p>Unable to run sample code on AWS Dynamodb.</p>

<p>I am trying to run the AWS sample python code that they provide on there website. Here is my python file:</p>

<pre><code>    from __future__ import print_function # Python 2/3 compatibility
    import boto3

   dynamodb = boto3.resource('dynamodb', region_name='us-west-2', endpoint_url="http://localhost:8000")


   table = dynamodb.create_table(
       TableName='Movies',
       KeySchema=[
           {
               'AttributeName': 'year',
               'KeyType': 'HASH'  #Partition key
           },
           {
               'AttributeName': 'title',
               'KeyType': 'RANGE'  #Sort key
           }
       ],
       AttributeDefinitions=[
           {
               'AttributeName': 'year',
               'AttributeType': 'N'
           },
           {
               'AttributeName': 'title',
               'AttributeType': 'S'
           },

       ],
       ProvisionedThroughput={
           'ReadCapacityUnits': 10,
           'WriteCapacityUnits': 10
       }
   )

   print("Table status:", table.table_status)
</code></pre>

<p>I then I run the python file in terminal and I get the following error:</p>

<pre><code>File "MoviesCreateTable.py", line 32, in &lt;module&gt;
    'WriteCapacityUnits': 10
File "/home/name/.local/lib/python2.7/site-packages/boto3/resources/factory.py", line 520, in do_action
    response = action(self, *args, **kwargs)
File "/home/name/.local/lib/python2.7/site-packages/boto3/resources/action.py", line 83, in __call__
    response = getattr(parent.meta.client, operation_name)(**params)
File "/home/name/.local/lib/python2.7/site-packages/botocore/client.py", line 159, in _api_call
    return self._make_api_call(operation_name, kwargs)
File "/home/name/.local/lib/python2.7/site-packages/botocore/client.py", line 483, in _make_api_call
    operation_model, request_dict)
File "/home/name/.local/lib/python2.7/site-packages/botocore/endpoint.py", line 141, in make_request
    return self._send_request(request_dict, operation_model)
File "/home/name/.local/lib/python2.7/site-packages/botocore/endpoint.py", line 170, in _send_request
    success_response, exception):
File "/home/name/.local/lib/python2.7/site-packages/botocore/endpoint.py", line 249, in _needs_retry
    caught_exception=caught_exception, request_dict=request_dict)
File "/home/name/.local/lib/python2.7/site-packages/botocore/hooks.py", line 227, in emit
    return self._emit(event_name, kwargs)
File "/home/name/.local/lib/python2.7/site-packages/botocore/hooks.py", line 210, in _emit
    response = handler(**kwargs)
File "/home/name/.local/lib/python2.7/site-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
File "/home/name/.local/lib/python2.7/site-packages/botocore/retryhandler.py", line 251, in __call__
    caught_exception)
File "/home/name/.local/lib/python2.7/site-packages/botocore/retryhandler.py", line 277, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
File "/home/name/.local/lib/python2.7/site-packages/botocore/retryhandler.py", line 317, in __call__
    caught_exception)
File "/home/name/.local/lib/python2.7/site-packages/botocore/retryhandler.py", line 223, in __call__
    attempt_number, caught_exception)
File "/home/name/.local/lib/python2.7/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
botocore.vendored.requests.exceptions.ConnectionError: ('Connection aborted.', error(111, 'Connection refused'))
</code></pre>

<p>This happens when Dynamodb isn't running. Check <code>localhost:8000/shell</code> to verify it's running.</p>

<p>Ensure all the <a href="http://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/GettingStarted.Python.html" rel="nofollow">prerequisites</a> given in docs are satisfied.</p>

<blockquote>
  <p>Before you begin this tutorial, you need to do the following:</p>
  
  <ul>
  <li>Download and run DynamoDB on your computer. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/GettingStarted.JsShell.html#GettingStarted.JsShell.Prereqs.Download" rel="nofollow">Download and Run
  DynamoDB</a>.</li>
  <li>Sign up for Amazon Web Services and create access keys. You need these credentials to use AWS SDKs. To create an AWS account, go to
  <a href="http://aws.amazon.com/" rel="nofollow">http://aws.amazon.com/</a>, choose Create an AWS Account, and then follow
  the online instructions.</li>
  <li>Create an AWS credentials file. For more information, see Configuration in the Boto 3 documentation.</li>
  <li>Install Python 2.6 or later. For more information, see <a href="https://www.python.org/downloads" rel="nofollow">https://www.python.org/downloads</a>.</li>
  </ul>
</blockquote>

python python-2.7 ubuntu amazon-web-services amazon-dynamodb