saketkc / pysradb

Package for fetching metadata and downloading data from SRA/ENA/GEO
https://saketkc.github.io/pysradb
BSD 3-Clause "New" or "Revised" License
307 stars 50 forks source link

[BUG] Failed to establish a new connection: [Errno -2] Name or service not known #169

Closed Thanakron1997 closed 1 year ago

Thanakron1997 commented 1 year ago

When I search

pysradb metadata PRJNA242847 --detailed --saveto my_file

and it gives this error

Traceback (most recent call last):
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/urllib3/connection.py", line 159, in _new_conn
    conn = connection.create_connection(
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/urllib3/util/connection.py", line 61, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
    conn.connect()
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/urllib3/connection.py", line 309, in connect
    conn = self._new_conn()
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/urllib3/connection.py", line 171, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f7e6cf81490>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/home/tiravut.per/.local/lib/python3.8/site-packages/requests/adapters.py", line 440, in send
    resp = conn.urlopen(
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/urllib3/connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/urllib3/util/retry.py", line 446, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='eutils.ncbi.nlm.nih.gov', port=443): Max retries exceeded with url: /entrez/eutils/efetch.fcgi?db=sra&usehistory=n&retmode=runinfo&query_key=1&WebEnv=MCID_63aaa3dd8528da49417c64ca&retstart=4500&retmax=500 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f7e6cf81490>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/apps/modules/software/Anaconda3/2020.11/bin/pysradb", line 8, in <module>
    sys.exit(parse_args())
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/pysradb/cli.py", line 1202, in parse_args
    metadata(
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/pysradb/cli.py", line 79, in metadata
    df = sradb.sra_metadata(
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/pysradb/sraweb.py", line 548, in sra_metadata
    efetch_result = self.get_efetch_response("sra", srp)
  File "/data/apps/modules/software/Anaconda3/2020.11/lib/python3.8/site-packages/pysradb/sraweb.py", line 349, in get_efetch_response
    request = requests.get(self.base_url["efetch"], params=OrderedDict(payload))
  File "/data/home/tiravut.per/.local/lib/python3.8/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/data/home/tiravut.per/.local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/data/home/tiravut.per/.local/lib/python3.8/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/data/home/tiravut.per/.local/lib/python3.8/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/data/home/tiravut.per/.local/lib/python3.8/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='eutils.ncbi.nlm.nih.gov', port=443): Max retries exceeded with url: /entrez/eutils/efetch.fcgi?db=sra&usehistory=n&retmode=runinfo&query_key=1&WebEnv=MCID_63aaa3dd8528da49417c64ca&retstart=4500&retmax=500 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f7e6cf81490>: Failed to establish a new connection: [Errno -2] Name or service not known'))

Thank you.

Desktop (please complete the following information):

saketkc commented 1 year ago

This appears to be due to an intermittent connection error at the NCBI end. I just tried it and it worked without any errors. Please try again.