ConnectionRefusedError:[Errno 61]连接被拒绝&无法连接到端点URL:http://127.0.0.1:3001

时间:2019-08-22 16:49:02

标签: python amazon-web-services amazon-s3 aws-lambda botocore

我正在尝试使用boto3和aws运行集成测试。似乎测试无法连接到localhost端点,因此测试失败。我很确定我已经正确配置了aws环境变量。我怀疑也许没有本地服务器在运行,但是我仍然不确定如何解决该问题。任何帮助将不胜感激。

我在Mac Mojave上运行,我尝试过更改服务器试图连接到localhost:3000的端口。我还尝试使用AWS Step Functions(https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-config-options.html)连接到正在运行的服务器,但是没有运气。

来自日志的错误消息:

ConnectionRefusedError: [Errno 61] Connection refused

raise EndpointConnectionError(endpoint_url=request.url, error=e)
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:3001/2015-03-31/functions/AthenaDatabaseProvider/invocations"

完整日志:

Traceback (most recent call last):
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/util/connection.py", line 70, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/httpsession.py", line 262, in send
    chunked=self._chunked(request.headers),
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/util/retry.py", line 344, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/packages/six.py", line 686, in reraise
    raise value
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
    chunked=chunked)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/connectionpool.py", line 355, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/awsrequest.py", line 125, in _send_request
    method, url, body, headers, *args, **kwargs)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1290, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1239, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/awsrequest.py", line 152, in _send_output
    self.send(msg)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/awsrequest.py", line 236, in send
    return super(AWSConnection, self).send(str)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/connection.py", line 183, in connect
    conn = self._new_conn()
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <botocore.awsrequest.AWSHTTPConnection object at 0x11ea50d90>: Failed to establish a new connection: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/patrickward/repositories/JAM/hobbes/transformations/tests/integration/lambdas/athena_database_provider_test.py", line 97, in test_drop_with_stack_false_keeps_database_on_delete
    invoke_fn(cloud_formation_event('Delete', DatabaseName=existent_database, DropWithStack='False'))
  File "/Users/patrickward/repositories/JAM/hobbes/transformations/tests/integration/lambdas/athena_database_provider_test.py", line 54, in _exec
    Payload=json.dumps(event)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/client.py", line 648, in _make_api_call
    operation_model, request_dict, request_context)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/client.py", line 667, in _make_request
    return self._endpoint.make_request(operation_model, request_dict)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/endpoint.py", line 102, in make_request
    return self._send_request(request_dict, operation_model)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/endpoint.py", line 137, in _send_request
    success_response, exception):
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/endpoint.py", line 231, in _needs_retry
    caught_exception=caught_exception, request_dict=request_dict)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/hooks.py", line 356, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/retryhandler.py", line 251, in __call__
    caught_exception)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/retryhandler.py", line 277, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/retryhandler.py", line 317, in __call__
    caught_exception)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/retryhandler.py", line 223, in __call__
    attempt_number, caught_exception)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/endpoint.py", line 200, in _do_get_response
    http_response = self._send(request)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/endpoint.py", line 244, in _send
    return self.http_session.send(request)
  File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/httpsession.py", line 282, in send
    raise EndpointConnectionError(endpoint_url=request.url, error=e)
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:3001/2015-03-31/functions/AthenaDatabaseProvider/invocations"

1 个答案:

答案 0 :(得分:0)

结果是,运行测试时,我需要运行docker应用。希望这可以帮助可能遇到相同问题的人!