Unable to post request to Infura (SSLError: EOF occurred in violation of protocol)

Hi all, I am new to IPFS and trying to create python script to upload some images to Infura IPFS.

I am trying to post my request like that:

endpoint = "https://ipfs.infura.io:5001"
response = requests.post(endpoint + '/api/v0/add?wrap-with-directory=true', files=files, auth=(projectId, projectSecret))

I get following error from requests library:

requests.exceptions.SSLError: HTTPSConnectionPool(host='ipfs.infura.io', port=5001): Max retries exceeded with url: /api/v0/add?wrap-with-directory=true (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:2396)')))

I tried to look for answers on stackoverflow, somebody recommends installing the following:

pip install ndg-httpsclient
pip install pyopenssl
pip install pyasn1

but it did not solve my issue. Any help would be really appreciated

Hey, are you getting the same error if you try without passing auth in requests.post ?

request.post works without passing auth data and seems like file is uploaded, but IPFS fails to load it.
Example of uploaded file (time outs): QmTstzGVWMM1ZdvSkYLcJNEx7iCfb92vzuNmBmnDzPcoF6

It seems to load fine via Infura gw, there is a propagation delay to the public gateway:


That is great, but how can I setup upload trough specific project on Infura so auth would work? Anybody faced similar issues trying to post Infura API requests using Python on Windows?

Weird, I’ve just tested this script with auth and it works well for me. Can you try to run it and see if you get the same error ? (replace the file path and auth data ofc):

import requests

import json

files = {

'file': (open('<file_path_here>', 'rb')),


project_id = '...'

project_secret = '...'

response = requests.post('https://ipfs.infura.io:5001/api/v0/add', files=files, auth=(project_id, project_secret))

p = response.json()

hash = p['Hash']