Ipfs.add() always "Request timed out"

async function uploadToIPFS(base64Data) {
try {
const auth = ‘Basic ’ + Buffer.from(config.infuraProjectId + ‘:’ + config.infuraProjectSecret).toString(‘base64’);
const ipfs = IPFS.create({
host: ‘ipfs.infura.io’,
port: 5001,
protocol: ‘https’,
apiPath: ‘/ipfs/api/v0’,
headers: {
authorization: auth,
timeout: 15000
const buffer = Buffer.from(base64Data, ‘base64’);
console.log(‘init add’);
const { cid } = await ipfs.add(buffer);

// Return the IPFS gateway URL for the uploaded file
const gatewayUrl = `https://ipfs.infura.io/${cid}`;
console.log('IPFS Gateway URL:', gatewayUrl);

return gatewayUrl;

} catch (error) {
console.error(‘Error uploading to IPFS:’, error.message);
throw error;

Always showing ‘Request timed out’. Why? Also, I would like to ask what the purpose of a dedicated gateway is?
External Image


Hi @evagreen and welcome to the community.

I noticed that you also opened a support ticket and you are trying to upload the content of a URL.
We have a support tip for doing just that using the kubo-rpc-client:

Otherwise you’ll need to let us know from which library you are importing the IPFS module in your code.
Also the purpose of a dedicated gateway is to view/access your CID in a browser after upload.

In order to view your CID after upload you should construct your URL in the following way:

More details on how to enable and configure your dedicated gateway can be found at the below link:

Hope this helps.



const IPFS = require(‘ipfs-http-client’);
I am using ipfs http client


hey @evagreen, the ipfs-http-client is deprecated and we recommend using the kubo-rpc-client instead, like explained in the previous tutorial I sent:

Give it a go, as it does pretty much what you are trying to do.

Also another tip which you might find useful is how add multiple files using the kubo client.

Hope this helps.


I have just used the Kubo URL tutorial I previously sent, to upload the content of the url you sent through the support ticket and it worked just fine.
I can access it now using my dedicated gateway, please see below screenshot

External Image


import { urlSource, create } from ‘kubo-rpc-client’;
//const {urlSource, create} = require(‘kubo-rpc-client’);

I encountered some issues when using the kubo-rpc-client library. I used Babelrc to configure it to parse and execute ESM and CJS, but there were always

error:internal/modules/CJS/loader. js:1080
Throw new ERR_ REQUIRE_ ESM (filename, parentPath, packageJsonPath);
Error [ERR_REQUIRE-ESM]: Must use import to load ES Module

My node version is v14.16.1, and I think it may be a problem caused by the node version. I have also tried using other versions of kubo-rpc-client, but still face the same problem. I cannot freely change the node version, so is there any other library that can replace kubo-rpc-client?


It seems that the issue is caused by the node version, but the version of the node cannot be changed freely in the project. I think that the library should be compatible with lower versions of nodeJs to have better compatibility.


Please take a look at my code, it is still timeout
External Image
External Image


Hi @evagreen, unfortunately I don’t know of any other library to replace the kubo-rpc-client. Regarding the backwards compatibility with older node versions maybe you can ask on their github, as the kubo client is not maintained by Infura.

The err_connection_timed_out usually means that there’s something wrong on your local network connection. Are you using a proxy or a vpn?

Also, could you try adding a file to IPFS using a simple curl just to see that uploads are indeed working from your side?
Please see the below doc and example in which you should specify a path to a file on your machine.

curl "https://ipfs.infura.io:5001/api/v0/add?pin=true" \
    -X POST \
    -u "<API_KEY>:<API_KEY_SECRET>" \
    -H "Content-Type: multipart/form-data" \
    -F file=@"/path/to/file/filename"

It seems like there are regional restrictions, even though IP access is already allowed in the infura backend, some IPs will still be request timeout. I succeeded on the server and thank you very much for your help! :clap:
External Image
External Image
External Image


That’s great news. Happy I could help. We will also close the support ticket you raised if that’s ok with you.

1 Like

Yes! Thank you very much again for your help! :slightly_smiling_face:


This topic was automatically closed after 30 days. New replies are no longer allowed.