greenfrogs/FHIR-Parser

ConnectionError: HTTPSConnectionPool(host='localhost', port=5001): Max retries exceeded with url: /api/Patient/8f789d0b-3145-4cf2-8504-13159edaa747 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f3a5d760390>: Failed to establish a new connection: [Errno 111] Connection refused'))

Closed this issue · 1 comments

I have installed FHIR-Parser and am trying to run it. I am getting Errno 111 - Connection refused.
Python version : 3.7.6

>> from fhir_parser import FHIR
>> fhir = FHIR()
>> patient = fhir.get_patient('8f789d0b-3145-4cf2-8504-13159edaa747')

Error
Traceback (most recent call last):
File "/home/admin/.local/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/home/admin/.local/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
raise err
File "/home/admin/.local/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/admin/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
chunked=chunked,
File "/home/admin/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 381, in _make_request
self._validate_conn(conn)
File "/home/admin/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
conn.connect()
File "/home/admin/.local/lib/python3.7/site-packages/urllib3/connection.py", line 309, in connect
conn = self._new_conn()
File "/home/admin/.local/lib/python3.7/site-packages/urllib3/connection.py", line 172, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f3a5d760390>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/admin/.local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/admin/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 727, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/home/admin/.local/lib/python3.7/site-packages/urllib3/util/retry.py", line 439, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='localhost', port=5001): Max retries exceeded with url: /api/Patient/8f789d0b-3145-4cf2-8504-13159edaa747 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f3a5d760390>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/home/admin/.local/lib/python3.7/site-packages/fhir_parser/fhir.py", line 73, in get_patient
response = requests.get(urllib.parse.urljoin(self.endpoint, 'Patient/' + str(id)), verify=self.verify_ssl)
File "/home/admin/.local/lib/python3.7/site-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/home/admin/.local/lib/python3.7/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/home/admin/.local/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/home/admin/.local/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/home/admin/.local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='localhost', port=5001): Max retries exceeded with url: /api/Patient/8f789d0b-3145-4cf2-8504-13159edaa747 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f3a5d760390>: Failed to establish a new connection: [Errno 111] Connection refused'))

You need to connect to a FHIR endpoint, either by running one locally with something like GOSH FHIRworks_2020: https://github.com/goshdrive/FHIRworks_2020 or you can connect to a hosted one by changing your connection string to:

fhir = FHIR(host='fhir-endpoint.com', port=5001)