Skip to content

[Python] AWS Error NETWORK_CONNECTION during HeadObject operation: curlCode: 6, Couldn't resolve host name #40539

Open

Description

@anjali-chadha

Describe the bug, including details regarding any error messages, version, and platform.

Hi there!

We are using the PyArrow library to read files from an S3 bucket, and we're encountering an intermittent error:

OSError: When reading information for key '<REDACTED>' in bucket '<REDACTED>': AWS Error NETWORK_CONNECTION during HeadObject operation: curlCode: 6, Couldn't resolve host name

Please note that this error doesn't occur consistently, and the S3 bucket path is valid.

The reference code we're using is as follows:

import pyarrow as pa
import pyarrow.json as pj

uri = "s3://my-bucket/my-prefix/foo.json"

fs, path = pa.fs.FileSystem.from_uri(uri)  

with fs.open_input_file(path) as f:
       tbl = pj.read_json(f)

Error Details:

2024-03-12T13:06:05.616-07:00    [7]: with fs.open_input_file(path) as f:

2024-03-12T13:06:05.616-07:00    [7]: File "pyarrow/_fs.pyx", line 780, in pyarrow._fs.FileSystem.open_input_file

2024-03-12T13:06:05.616-07:00    [7]: File "pyarrow/error.pxi", line 154, in pyarrow.lib.pyarrow_internal_check_status

2024-03-12T13:06:05.616-07:00    [7]: File "pyarrow/error.pxi", line 91, in pyarrow.lib.check_status

2024-03-12T13:06:05.616-07:00    [7]:OSError: When reading information for key '<REDACTED>' in bucket '<REDACTED>': AWS Error NETWORK_CONNECTION during HeadObject operation: curlCode: 6, Couldn't resolve host name

Could you please provide any suggestions on how to handle such intermittent network connectivity errors while reading from S3?

Component(s)

Parquet, Python

Activity

  1. changed the title [-]AWS Error NETWORK_CONNECTION during HeadObject operation: curlCode: 6, Couldn't resolve host name[/-] [+][Python][AWS Error NETWORK_CONNECTION during HeadObject operation: curlCode: 6, Couldn't resolve host name[/+] on Mar 14, 2024
  2. pitrou commented on Mar 14, 2024

    @pitrou
    Member

    Are you using AWS or do you set endpoint_override? "Couldn't resolve host name" probably means you're having issues with DNS resolution of the S3 server(s) hostnames, which is quite unexpected with AWS...

  3. changed the title [-][Python][AWS Error NETWORK_CONNECTION during HeadObject operation: curlCode: 6, Couldn't resolve host name[/-] [+][Python] AWS Error NETWORK_CONNECTION during HeadObject operation: curlCode: 6, Couldn't resolve host name[/+] on Mar 14, 2024
  4. anjali-chadha commented on Mar 15, 2024

    @anjali-chadha
    Author

    @pitrou Yes, we are using AWS, and not explicitly overriding endpoint_override

    you're having issues with DNS resolution of the S3 server(s) hostnames, which is quite unexpected with AWS...

    We've only encountered this problem once among our numerous runs, so it's not a frequent occurrence. Currently, our approach to dealing with this issue is by increasing the default number of S3 retry attempts from 3 to a higher value.

    if isinstance(fs, S3FileSystem):
        fs = pa.fs.S3FileSystem(
            region=fs.region, retry_strategy=AwsStandardS3RetryStrategy(max_attempts=6)
        )
    

    However, we're uncertain if this is the most effective approach.

    Do you have any recommendations on how we can better handle this on the client side?

  5. pitrou commented on Mar 16, 2024

    @pitrou
    Member

    Sorry, I don't have any recommandation. If increasing max_attempts works, then it seems ok to me.

  6. antonioalegria commented on Nov 4, 2024

    @antonioalegria

    I'm facing this issue when doing a scan_iceberg operation in Polars. It only happens with certain objects:

    When reading information for key '' in bucket '': AWS Error NETWORK_CONNECTION during HeadObject operation: curlCode: 6, Couldn't resolve host name
    Traceback (most recent call last):

    File "", line 351, in scan_table
    return pl.scan_iceberg(location)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/.venv/lib/python3.12/site-packages/polars/io/iceberg.py", line 143, in scan_iceberg
    source = StaticTable.from_metadata(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/.venv/lib/python3.12/site-packages/pyiceberg/table/init.py", line 1693, in from_metadata
    metadata = FromInputFile.table_metadata(file)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/.venv/lib/python3.12/site-packages/pyiceberg/serializers.py", line 113, in table_metadata
    with input_file.open() as input_stream:
    ^^^^^^^^^^^^^^^^^
    File "/.venv/lib/python3.12/site-packages/pyiceberg/io/pyarrow.py", line 270, in open
    input_file = self._filesystem.open_input_file(self._path)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "pyarrow/_fs.pyx", line 789, in pyarrow._fs.FileSystem.open_input_file
    File "pyarrow/error.pxi", line 155, in pyarrow.lib.pyarrow_internal_check_status
    File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
    OSError: When reading information for key '' in bucket '': AWS Error NETWORK_CONNECTION during HeadObject operation: curlCode: 6, Couldn't resolve host name

  7. hadim commented on Feb 21, 2025

    @hadim

    I am seeing the same error. What confuses me is that using fsspec directly, everything works fine. Note that I am using a custom S3 provider (scaleway object storage) and so I set a custom endpoint URL in the AWS config file.

    import fsspec
    import pandas as pd
    
    data_path = "s3://my-bucket/data/datafile.parquet"
    
    # This works fine 🟢
    with fsspec.open(data_path, mode="rb") as f:
        print(f.read(100))
    
    # This fails ❌
    pd.read_parquet(data_path)

    Using:

    pyarrow       19.0.1   py312h1f38498_0      24.9 KiB  conda  pyarrow
    pandas   2.2.3    py312hcd31e36_1  13.8 MiB  conda  pandas
    fsspec   2024.12.0  pyhd8ed1ab_0  134.5 KiB  conda  fsspec
  8. hadim commented on Feb 21, 2025

    @hadim

    Current working but not ideal (verbose) workaround is:

    import io
    import fsspec
    import pandas as pd
    
    with fsspec.open(proteome_path, mode="rb") as f:
        buffer = io.BytesIO(f.read())
        data = pd.read_parquet(buffer)
  9. harelo-cf commented on Mar 4, 2025

    @harelo-cf

    @hadim I face the same issue and it is a new issue, I never had that before - same code that we always used now fails on table creation.

    Did you manage to solve it?
    @Fokko

  10. thisisnic commented on Oct 26, 2026

    @thisisnic
    Member

    Original report answered as a client-side DNS resolution failure surfaced by the AWS SDK with AwsStandardS3RetryStrategy(max_attempts=N) as the mitigation, and the later me-toos are different setups (Polars/pyiceberg, a custom endpoint set only in ~/.aws/config) without a reprex; closing this as resolved. If anyone else encouters this, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions