Can't connect to IPFS Cluster REST API on port 9094

I have 2 different components each in a different container

  • Python backend
  • IPFS cluster

To integrate the Python backend with IPFS cluster I’m using requests library.

To test the integration, created a test Python file

import requests

url = "IPFS_CLUSTER_IP:9094/id"

payload={}

headers={}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

If I run it like that, then I get an error that shows we need to use Protocol Schema - Python Requests - No connection adapters - Stack Overflow

If add the Protocol Schema, url = "http://IPFS_CLUSTER_IP:9094/id", then that doesn’t work.

Traceback (most recent call last):
File “/code/api/tester.py”, line 5, in
response = requests.request(“GET”, url, headers=headers, data=payload)
File “/usr/lib/python3.9/site-packages/requests/api.py”, line 61, in request
return session.request(method=method, url=url, **kwargs)
File “/usr/lib/python3.9/site-packages/requests/sessions.py”, line 542, in request
resp = self.send(prep, **send_kwargs)
File “/usr/lib/python3.9/site-packages/requests/sessions.py”, line 655, in send
r = adapter.send(request, **kwargs)
File “/usr/lib/python3.9/site-packages/requests/adapters.py”, line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘IPFS_CLUSTER_IP’, port=9094): Max retries exceeded with url: /id (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0x7f1bf1c566a0>: Failed to establish a new connection: [Errno 111] Connection refused’))

If I Port Forward, I’m able to connect to that IPFS Cluster port from my machine.

That was fixed by exposing it via a Load Balancer.

1 Like