serverless-localstack icon indicating copy to clipboard operation
serverless-localstack copied to clipboard

An error occurred (404) when calling the HeadObject operation: Not Found Traceback

Open rsosnin opened this issue 5 years ago • 6 comments

While using localstack:0.10.8 , I'm getting an error when trying to put object in the local s3 bucket. More details:

2020-03-22T11:21:47:ERROR:localstack.services.generic_proxy: Error forwarding request: An error occurred (404) when calling the HeadObject operation: Not Found Traceback (most recent call last):
localstack               |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 303, in forward
localstack               |     updated_response = self.proxy.update_listener.return_response(**kwargs)
localstack               |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 1000, in return_response
localstack               |     fix_range_content_type(bucket_name, path, headers, response)
localstack               |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 380, in fix_range_content_type
localstack               |     result = s3_client.head_object(Bucket=bucket_name, Key=key_name)
localstack               |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 316, in _api_call
localstack               |     return self._make_api_call(operation_name, kwargs)
localstack               |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 626, in _make_api_call
localstack               |     raise error_class(parsed_response, operation_name)
localstack               | botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found

My code snippet:

file_to_upload = open(file_path, 'rb')
response = s3_client.put_object(
        ACL='public-read-write',
        Body=file_to_upload,
        Bucket=function_s3_bucket,
        Key=function_s3_key
    )

With localstack:0.9.6 I don't get this error and everything works as expected

┆Issue is synchronized with this Jira Task by Unito

rsosnin avatar Mar 22 '20 11:03 rsosnin

I could get it working using localstack/localstack:0.10.6

michcald avatar Apr 27 '20 13:04 michcald

Got the same problem today. Something might be useful is: it seems the bucket name is duplicated in the HEAD calls:

localstack                     | 2020-05-18 18:12:10,266:API: 127.0.0.1 - - [18/May/2020 18:12:10] "GET /hollow/test/snapshot/30e68532-20200518173030001 HTTP/1.1" 206 -
localstack                     | 2020-05-18 18:12:10,266:API: 127.0.0.1 - - [18/May/2020 18:12:10] "GET /hollow/test/snapshot/30e68532-20200518173030001 HTTP/1.1" 206 -
localstack                     | 2020-05-18 18:12:10,266:API: 127.0.0.1 - - [18/May/2020 18:12:10] "GET /hollow/test/snapshot/30e68532-20200518173030001 HTTP/1.1" 206 -
localstack                     | 2020-05-18 18:12:10,276:API: 127.0.0.1 - - [18/May/2020 18:12:10] "HEAD /hollow/hollow HTTP/1.1" 404 -
localstack                     | 2020-05-18 18:12:10,276:API: 127.0.0.1 - - [18/May/2020 18:12:10] "HEAD /hollow/hollow HTTP/1.1" 404 -
localstack                     | 2020-05-18 18:12:10,276:API: 127.0.0.1 - - [18/May/2020 18:12:10] "HEAD /hollow/hollow HTTP/1.1" 404 -

xiao-pp avatar May 18 '20 18:05 xiao-pp

Thanks for reporting @rsosnin @michcald @xiao-pp . Can you please do a docker pull localstack/localstack and let us know if this problem still persists with the latest version of the Docker image? Thanks for your help.

whummer avatar Jul 29 '20 17:07 whummer

I'm also having this 404 issue, but with the get-object method. I can successfully execute the put-object method, and add a new file inside an S3 bucket. However, when I execute the get-object method for that object, it fails with the 404 error. I've tested with AWS CLI and everything works fine, and I can get the file correctly.

Here is the localstack output (errors when "reading" a file):

localstack      | 2020-09-29T21:09:08:WARNING:bootstrap.py: Thread run method <function AdaptiveThreadPool.submit.<locals>._run at 0x7f154f4d3700>(None) failed: An error occurred (404) when calling the HeadObject operation: Not Found Traceback (most recent call last):
localstack      |   File "/opt/code/localstack/localstack/utils/bootstrap.py", line 533, in run
localstack      |     result = self.func(self.params)
localstack      |   File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
localstack      |     return fn(*args, **kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 557, in handler
localstack      |     response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 332, in modify_and_forward
localstack      |     listener_result = listener.forward_request(method=method,
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
localstack      |     return do_forward_request(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
localstack      |     result = do_forward_request_inmem(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
localstack      |     response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 400, in modify_and_forward
localstack      |     updated_response = update_listener.return_response(**kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 1224, in return_response
localstack      |     fix_range_content_type(bucket_name, path, headers, response)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 448, in fix_range_content_type
localstack      |     result = s3_client.head_object(Bucket=bucket_name, Key=key_name)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 337, in _api_call
localstack      |     return self._make_api_call(operation_name, kwargs)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 656, in _make_api_call
localstack      |     raise error_class(parsed_response, operation_name)
localstack      | botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found
localstack      | 
localstack      | 2020-09-29T21:09:08:WARNING:localstack.utils.server.http2_server: Error in proxy handler for request GET http://localhost/local-wolverine-territory-store/territories_claudia.json: An error occurred (404) when calling the HeadObject operation: Not Found Traceback (most recent call last):
localstack      |   File "/opt/code/localstack/localstack/utils/server/http2_server.py", line 94, in index
localstack      |     raise result
localstack      |   File "/opt/code/localstack/localstack/utils/bootstrap.py", line 533, in run
localstack      |     result = self.func(self.params)
localstack      |   File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
localstack      |     return fn(*args, **kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 557, in handler
localstack      |     response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 332, in modify_and_forward
localstack      |     listener_result = listener.forward_request(method=method,
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
localstack      |     return do_forward_request(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
localstack      |     result = do_forward_request_inmem(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
localstack      |     response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 400, in modify_and_forward
localstack      |     updated_response = update_listener.return_response(**kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 1224, in return_response
localstack      |     fix_range_content_type(bucket_name, path, headers, response)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 448, in fix_range_content_type
localstack      |     result = s3_client.head_object(Bucket=bucket_name, Key=key_name)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 337, in _api_call
localstack      |     return self._make_api_call(operation_name, kwargs)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 656, in _make_api_call
localstack      |     raise error_class(parsed_response, operation_name)
localstack      | botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found
localstack      | 
localstack      | 2020-09-29T21:09:08:WARNING:bootstrap.py: Thread run method <function AdaptiveThreadPool.submit.<locals>._run at 0x7f154ff58820>(None) failed: An error occurred (404) when calling the HeadObject operation: Not Found Traceback (most recent call last):
localstack      |   File "/opt/code/localstack/localstack/utils/bootstrap.py", line 533, in run
localstack      |     result = self.func(self.params)
localstack      |   File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
localstack      |     return fn(*args, **kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 557, in handler
localstack      |     response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 332, in modify_and_forward
localstack      |     listener_result = listener.forward_request(method=method,
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
localstack      |     return do_forward_request(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
localstack      |     result = do_forward_request_inmem(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
localstack      |     response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 400, in modify_and_forward
localstack      |     updated_response = update_listener.return_response(**kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 1224, in return_response
localstack      |     fix_range_content_type(bucket_name, path, headers, response)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 448, in fix_range_content_type
localstack      |     result = s3_client.head_object(Bucket=bucket_name, Key=key_name)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 337, in _api_call
localstack      |     return self._make_api_call(operation_name, kwargs)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 656, in _make_api_call
localstack      |     raise error_class(parsed_response, operation_name)
localstack      | botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found
localstack      | 
localstack      | 2020-09-29T21:09:08:WARNING:localstack.utils.server.http2_server: Error in proxy handler for request GET http://localhost/local-wolverine-territory-store/territories_claudia.json: An error occurred (404) when calling the HeadObject operation: Not Found Traceback (most recent call last):
localstack      |   File "/opt/code/localstack/localstack/utils/server/http2_server.py", line 94, in index
localstack      |     raise result
localstack      |   File "/opt/code/localstack/localstack/utils/bootstrap.py", line 533, in run
localstack      |     result = self.func(self.params)
localstack      |   File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
localstack      |     return fn(*args, **kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 557, in handler
localstack      |     response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 332, in modify_and_forward
localstack      |     listener_result = listener.forward_request(method=method,
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
localstack      |     return do_forward_request(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
localstack      |     result = do_forward_request_inmem(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
localstack      |     response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 400, in modify_and_forward
localstack      |     updated_response = update_listener.return_response(**kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 1224, in return_response
localstack      |     fix_range_content_type(bucket_name, path, headers, response)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 448, in fix_range_content_type
localstack      |     result = s3_client.head_object(Bucket=bucket_name, Key=key_name)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 337, in _api_call
localstack      |     return self._make_api_call(operation_name, kwargs)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 656, in _make_api_call
localstack      |     raise error_class(parsed_response, operation_name)
localstack      | botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found
localstack      | 
localstack      | 2020-09-29T21:09:09:WARNING:bootstrap.py: Thread run method <function AdaptiveThreadPool.submit.<locals>._run at 0x7f154f8c7310>(None) failed: An error occurred (404) when calling the HeadObject operation: Not Found Traceback (most recent call last):
localstack      |   File "/opt/code/localstack/localstack/utils/bootstrap.py", line 533, in run
localstack      |     result = self.func(self.params)
localstack      |   File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
localstack      |     return fn(*args, **kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 557, in handler
localstack      |     response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 332, in modify_and_forward
localstack      |     listener_result = listener.forward_request(method=method,
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
localstack      |     return do_forward_request(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
localstack      |     result = do_forward_request_inmem(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
localstack      |     response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 400, in modify_and_forward
localstack      |     updated_response = update_listener.return_response(**kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 1224, in return_response
localstack      |     fix_range_content_type(bucket_name, path, headers, response)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 448, in fix_range_content_type
localstack      |     result = s3_client.head_object(Bucket=bucket_name, Key=key_name)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 337, in _api_call
localstack      |     return self._make_api_call(operation_name, kwargs)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 656, in _make_api_call
localstack      |     raise error_class(parsed_response, operation_name)
localstack      | botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found
localstack      | 
localstack      | 2020-09-29T21:09:09:WARNING:localstack.utils.server.http2_server: Error in proxy handler for request GET http://localhost/local-wolverine-territory-store/territories_claudia.json: An error occurred (404) when calling the HeadObject operation: Not Found Traceback (most recent call last):
localstack      |   File "/opt/code/localstack/localstack/utils/server/http2_server.py", line 94, in index
localstack      |     raise result
localstack      |   File "/opt/code/localstack/localstack/utils/bootstrap.py", line 533, in run
localstack      |     result = self.func(self.params)
localstack      |   File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
localstack      |     return fn(*args, **kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 557, in handler
localstack      |     response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 332, in modify_and_forward
localstack      |     listener_result = listener.forward_request(method=method,
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
localstack      |     return do_forward_request(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
localstack      |     result = do_forward_request_inmem(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
localstack      |     response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 400, in modify_and_forward
localstack      |     updated_response = update_listener.return_response(**kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 1224, in return_response
localstack      |     fix_range_content_type(bucket_name, path, headers, response)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 448, in fix_range_content_type
localstack      |     result = s3_client.head_object(Bucket=bucket_name, Key=key_name)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 337, in _api_call
localstack      |     return self._make_api_call(operation_name, kwargs)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 656, in _make_api_call
localstack      |     raise error_class(parsed_response, operation_name)
localstack      | botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found
localstack      | 
territory_1     | time="2020-09-29T21:09:09Z" level=error msg="Error, internal server error" correlation-id= error="Unable to get territories config for alias claudia: There is a problem reading from s3: : InternalServerError: Internal Server Error\n\tstatus code: 500, request id: , host id: " http-status=500 request-id=1iCZtTq6Qz7T0q06P9WBfuSvD6d service=local-wolverine
localstack      | 2020-09-29T21:09:09:WARNING:bootstrap.py: Thread run method <function AdaptiveThreadPool.submit.<locals>._run at 0x7f155012b310>(None) failed: An error occurred (404) when calling the HeadObject operation: Not Found Traceback (most recent call last):
localstack      |   File "/opt/code/localstack/localstack/utils/bootstrap.py", line 533, in run
localstack      |     result = self.func(self.params)
localstack      |   File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
localstack      |     return fn(*args, **kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 557, in handler
localstack      |     response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 332, in modify_and_forward
localstack      |     listener_result = listener.forward_request(method=method,
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
localstack      |     return do_forward_request(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
localstack      |     result = do_forward_request_inmem(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
localstack      |     response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 400, in modify_and_forward
localstack      |     updated_response = update_listener.return_response(**kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 1224, in return_response
localstack      |     fix_range_content_type(bucket_name, path, headers, response)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 448, in fix_range_content_type
localstack      |     result = s3_client.head_object(Bucket=bucket_name, Key=key_name)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 337, in _api_call
localstack      |     return self._make_api_call(operation_name, kwargs)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 656, in _make_api_call
localstack      |     raise error_class(parsed_response, operation_name)
localstack      | botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found
localstack      | 
localstack      | 2020-09-29T21:09:09:WARNING:localstack.utils.server.http2_server: Error in proxy handler for request GET http://localhost/local-wolverine-territory-store/territories_claudia.json: An error occurred (404) when calling the HeadObject operation: Not Found Traceback (most recent call last):
localstack      |   File "/opt/code/localstack/localstack/utils/server/http2_server.py", line 94, in index
localstack      |     raise result
localstack      |   File "/opt/code/localstack/localstack/utils/bootstrap.py", line 533, in run
localstack      |     result = self.func(self.params)
localstack      |   File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
localstack      |     return fn(*args, **kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 557, in handler
localstack      |     response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 332, in modify_and_forward
localstack      |     listener_result = listener.forward_request(method=method,
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
localstack      |     return do_forward_request(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
localstack      |     result = do_forward_request_inmem(api, port, method, path, data, headers)
localstack      |   File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
localstack      |     response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
localstack      |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 400, in modify_and_forward
localstack      |     updated_response = update_listener.return_response(**kwargs)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 1224, in return_response
localstack      |     fix_range_content_type(bucket_name, path, headers, response)
localstack      |   File "/opt/code/localstack/localstack/services/s3/s3_listener.py", line 448, in fix_range_content_type
localstack      |     result = s3_client.head_object(Bucket=bucket_name, Key=key_name)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 337, in _api_call
localstack      |     return self._make_api_call(operation_name, kwargs)
localstack      |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 656, in _make_api_call
localstack      |     raise error_class(parsed_response, operation_name)
localstack      | botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found

And this is the command with AWS CLI that works well:

aws --endpoint-url=http://localhost:4566 s3api get-object --bucket myBucket --key "myFile.json" "/tmp/xxx.json"

I've noticed that localstack is trying to access "locahost" instead of "localhost:4566"... is that fine?

I'm using latest image (localstack:latest).

This is the output with a more verbose version (localstack-full:latest):

localstack      | [2020-09-29 22:04:22 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:22] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:22 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:22] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:22 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:22] "POST / HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:23 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:23] "POST  HTTP/1.1" 200 -
...
localstack      | [2020-09-29 22:04:23 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:23] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:23 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:23] "PUT /local-my-bucket/my_file.json HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:23 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:23] "POST  HTTP/1.1" 200 -
...
territory_1     | 2020/09/29 22:04:35 Trying to read file  my_file.json from bucket local-my-bucket
localstack      | [2020-09-29 22:04:35 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:35] "POST  HTTP/1.1" 200 -
...
localstack      | [2020-09-29 22:04:35 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:35] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:35 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:35] "GET /local-my-bucket/my_file.json HTTP/1.1" 404 -
localstack      | [2020-09-29 22:04:35 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:35] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:35 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:35] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:35 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:35] "HEAD /local-my-bucket HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "GET /local-my-bucket?website HTTP/1.1" 404 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "HEAD /local-my-bucket/local-my-bucket HTTP/1.1" 404 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "GET /local-my-bucket/my_file.json HTTP/1.1" 404 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "HEAD /local-my-bucket HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:36 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:36] "GET /local-my-bucket?website HTTP/1.1" 404 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "HEAD /local-my-bucket/local-my-bucket HTTP/1.1" 404 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "GET /local-my-bucket/my_file.json HTTP/1.1" 404 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "HEAD /local-my-bucket HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "GET /local-my-bucket?website HTTP/1.1" 404 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "HEAD /local-my-bucket/local-my-bucket HTTP/1.1" 404 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:37 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:37] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "GET /local-my-bucket/my_file.json HTTP/1.1" 404 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "HEAD /local-my-bucket HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "GET /local-my-bucket?website HTTP/1.1" 404 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "HEAD /local-my-bucket/local-my-bucket HTTP/1.1" 404 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
territory_1     | time="2020-09-29T22:04:38Z" level=error msg="Error, internal server error" correlation-id= error="Unable to get config file my_file: There is a problem reading from s3: : InternalServerError: Internal Server Error\n\tstatus code: 500, request id: , host id: " http-status=500 request-id=1iCgdX7Vh4BpHobpqpAKogHKLiN service=local-myService
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
localstack      | [2020-09-29 22:04:38 +0000] [23] [INFO] 172.21.0.2 - - [29/Sep/2020 22:04:38] "POST  HTTP/1.1" 200 -
...

crostagnol avatar Sep 29 '20 21:09 crostagnol

I was experiencing the same issue. It's due to the external hostname being incorrect for localstack. To resolve this, I set this:

HOSTNAME_EXTERNAL=localstack

If you're using a hostname other than localstack, you'll need to use that value instead.

CodeWonderer avatar Dec 04 '20 09:12 CodeWonderer

I was experiencing the same issue. It's due to the external hostname being incorrect for localstack. To resolve this, I set this:

HOSTNAME_EXTERNAL=localstack

If you're using a hostname other than localstack, you'll need to use that value instead.

thank you - this solved the issue for me!

ktamas77 avatar Dec 15 '20 08:12 ktamas77

Closing the issue because of inactivity. The issue should be resolved in the latest localstack version.

steffyP avatar Oct 13 '23 09:10 steffyP