saveIPFS() returns CORS policy error

Whenever I call saveIPFS() to upload a file I am returned the following:

Access to XMLHttpRequest at ‘’ from origin ‘http://localhost:2526’ has been blocked by CORS policy

Here’s the sample code and console response:

This was working for me yesterday, and I do not think I have changed related to this functionality in my code. I have tried updating to the latest moralis and react-moralis SDKs in my package.json npm file, as well as I just performed a restart+update on my server but the issue remains the same. This seemed to have just started yesterday.

In package.json I have tried with
moralis": “^0.0.138” as well as moralis": “^0.0.165”
and a few different versions of “react-moralis” package.

I did some searching in the forum and I found this: Sudden CORS errors but I wasn’t sure if I am experiencing the same/related backend issue or if there’s just some silly issue on my local devices/dependancies which I need to debug further.

Any next steps or direction on where to troubleshoot further would be appreciated! :pray:

do you get that error instantly or after a period of time like a timeout?

you could also try to upload from a cloud function now:

It is after some time the server responds to the browser with the CORS blocked error. Now that I look closer in my repro, this looks like a potential 60 second timeout, here’s the duration it took to respond:

you get CORS errors in case of timeout

Okay, thanks for confirming. I am still not sure why the server timeout is happening, though. The metadata file I am uploading is only a few kb in size so the backend should be able to process that within 60 seconds. And I had this was working yesterday with the same file so it seems odd.

I can explore the Moralis.Cloud.toIpfs method you linked above and report back how that goes, but I am still curious why this saveIPFS() is not working.

I have the same problem with uploading files to IPFS. This happesn in a for loop, where I upload multiple files. Some of them get uploaded but the others fail.

Here is the function:

const ipfsUploadFiles = async (files) => {
    const uploadedFilesIpfsUrls = [];
    for (var i = 0; i < files.length; i++) {
        const file = files[i];
        const ipfsFile = new Moralis.File(, file);
        await ipfsFile.saveIPFS(); // error happens here
        const ipfsFilePath = ipfsFile.ipfs();
        const fileInfo = { id: i + 1, fileName:, url: ipfsFilePath };
        console.log(`Successfully uploaded file`, fileInfo);
    return uploadedFilesIpfsUrls;

There are two requests to the server, preflight succeeds, but then thre real request fails. After that, all request fail. The uploading file is visible in payload and has a value written in base64 property. The size of the file is 9.4MB. The request response code is 502.

I tried to add some delay in the upload function loop, but I got same results. I also tried to change the site address from localhost:30000 to 1270.0.0.1:3000 but it’s the same. The third thing that I checked was an article on Morails about CORS, but it is not helpfull. When I wrapped the call into a try-catch, I got this message:

Error: XMLHttpRequest failed: “Unable to connect to the Parse API”

Is there any limitation on the Morails service that is not described? Sould I just disable cors in my browser?

Used versions:

  • Moralis server version: v0.0.385 (Free development tier)
  • Environment: Ganache
  • Moralis NPM package (The Moralis JavaScript SDK): 1.11.0 (tried also 0.0.176)
  • React Morails NPM package: 1.4.2 (tried also 0.3.11)

there is a rate limit for IPFS upload, you can try to add some delay between uploads

it cloud also be that the server is not able to handle the uploads any more and that is why you could get those CORS errors, you will see CORS errors when the server stops responding

I added a delay of 5s between uploads, but it was the same. Are there any specifications about max files sizes, max requests, etc. for test servers?
Is it possible to check ‘logs’ for a server instance?
Is possible, that the rate limit 25req/sec is exceeded while uploading in any case?

you can try to use the api directly to upload a file (it is not the same thing as the api uploads a folder)

there is a size limit, I don’t know what it is now, the server will restart if you try to upload a bigger file, mostly because it doesn’t have enough RAM to handle it

you can also try to use pinata

1 Like

What do you mean by ‘api directly’?

I purchased a PRO plan today, so that the server would have more RAM to operate. But that did not help me, since it looks like servers on test net get the same small amout as in free plan!
This made me very dissapointed.

How can I test the service and be sure that it will work on production if something as simple as using a function specified in docs is not working?

What do you mean by ‘api directly’?

He is talking about uploadFolder. This may be more suitable for uploading a batch of files to IPFS.

I purchased a PRO plan today

Upgrading to Pro plan does not change your server resources like RAM. Upgrading servers is an additional cost - you can see the differences in plans here.