Ipfs gateway slow

I know This question might have been asked many times, but i’d appreciate the answer in 2021 too.

Basically, I use ipfs-desktop on mac. Then , I add it as ipfs add filename.txt

Then i check it on myowngateway.com/ipfs/cid and also on ipfs.io/ipfs/cid

As it turns out, myowngateway.com is so slow that 98% of the time, it never resolves to a file and just returns 504 timed out. As for the ipfs.io , 85-90% of the time, it resolves to a file somehow quickly(sometimes takes 5 min too), but sometimes it just never resolves and hangs indefinatelly.

After I do ipfs add filename.txt, I also check on another computer this command: ipfs cat cid and it turns out this is super fast , immediatelly returns the file…

Question 1: How can I make sure that my gateway is fast and not this slow (as in never resolving to a file). Note that if ipfs.io gateway loads the file, then my gateway also starts loading it instantly.

Question 2: If I don’t use gateway, is there any chance that i can do ipfs fetch from javascript ? I know that ipfs cat is a terminal command, but anything like this from javascript and still not using gateway ?

  1. You can connect to your gateway node manually. Use ipfs swarm connect /p2p/<node_id>

@FledgeXu Thanks for your answer…

One more thing I might ask…

So I started the node on computerA. it could be started from the package you linked or any other daemons.

Now, on computerB, I have cid1 which i need to fetch. How do I get it from computerA ? I couldn’t see this example in the linked js-ipfs package.

Thank you in advance.

You don’t need to think something like “I need to fetch data from computer A “. In IPFS, data stores in which computer doesn’t matter and you just need think “I want to this file in IPFS and I don’t care where the data store.”


I agree, but I don’t want computerB to start a node. This is because computerB is a front-end app running in browser. So i need to make a call and get the file somehow. Since gateways are too slow,
I am looking for the alternatives.

Couldn’t find anything in js-ipfs package.

Any ideas ?

I think there is not a way can offer quick fetch files neither gateway or IPFS-node in browser.
Gateway node will cache the file, so after first loading the latter fetch should be quick.


I couldn’t quite understand what you said.

So you’re saying that it’s impossible without gateway ? if so, why are gateways so slow ?

Sorry I’m not native English speaker. I mean if you want the “fast first loading”. The gateway and In browser IPFS node are both not suited for you. Because they both need time to search the file in DHT network.
However, if you use gateway, when first user visits a file from the gateway, that gateway will cache the file. So that, when second people visits the same file, gateway doesn’t need search file again and it can just return file and that’ll be quick.


Clear, but gateways sometimes are so slow. ipfs and my own gateway can’t even return the file that I submitted to ipfs 4 hours ago…

So, what’s the workaround ?

Did you just close your local node after uploading the file? Other IPFS nodes won’t save your files automatically, unless they get your files.

I think the best way to offer quick files fetch is saving files to your gateway node. Basically, it’s a traditional Client-Server model. However, it also provides a IPFS cid that users can visit or pin use IPFS node.


Nope. would closing make any different ? I don’t think so.

The problem is that users can upload to ipfs and they just pass their cid to my function and I have no control which node they used.

I don’t really know that the use case you are meeting. :joy:
Maybe you meet the a same like this.