[SOLVED] "Unable to connect to the Parse API" on NodeJS

Iā€™ve attempted to run Moralis on NodeJS but I keep getting this error:

ParseError: XMLHttpRequest failed: "Unable to connect to the Parse API"
    at handleError (C:\Users\38976\node_modules\moralis\lib\node\RESTController.js:436:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 100
}

What is your code? Usually this error means that you didnā€™t set Application ID and SERVER_URL.

const Moralis = require(ā€˜moralis/nodeā€™);

Moralis.initialize(ā€˜APPIDā€™);

Moralis.serverURL = ā€˜ServerURLā€™;

Both are set but canā€™t get it to initialize. This APPID and ServerURL work on the web version but not on nodejs

This works fine for me:


x = async () => {
    const  Moralis = require('moralis/node')
    Moralis.initialize("APP_ID")
    Moralis.serverURL = "SERVER_URL"
    const options = {address: "0xe9e7cea3dedca5984780bafc599bd69add087d56", chain: "bsc"}
    tokenInfo = await Moralis.Web3API.token.getTokenPrice(options)
    console.log(tokenInfo)
    }

x();

Just tried this but still the same error

what you get if you run this:

const Moralis = require('moralis/node')
console.log(Moralis.CoreManager.get("VERSION"))

Found the issue. The connection was failing because I had proxy running on the background.

Iā€™m having the same problem as Konflict
I have double checked that I have well indicated my Server URL, APP ID , Masterkey, API URL and API key in the index.js file as well as config.js.
I still get ā€œError [ERR_FR_MAX_BODY_LENGTH_EXCEEDED]: Request body larger than maxBodyLength limitā€

as well as " ParseError: XMLHttpRequest failed: ā€œUnable to connect to the Parse APIā€.
and Json metadata does not get generated.

Any chance you would know what could cause those errors, your help would be greatly appreciated .
Thank you so much in advance :slight_smile:

hi I have checked all the enviornment variables
NODE_ENV=dev

APP_ID=ā€œKy5U0w45UsFaLAB5xOOF2865JwXdgFs2ujX2krBDā€

API_URL=ā€œhttps://deep-index.moralis.io/api-docs/#/storage/uploadFolderā€

API_KEY=ā€œmyapikey in hereā€

SERVER_URL=ā€œhttps://wimlepcpcnuo.usemoralis.com:2053/serverā€

MASTER_KEY=ā€œmy master key in hereā€
how ever i get this error

Error: Request failed with status code 404
at createError (C:\moralis-mutant-nftengine\moralis-mutants-nft-engine\node_modules\axios\lib\core\createError.js:16:15)
at settle (C:\moralis-mutant-nftengine\moralis-mutants-nft-engine\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (C:\moralis-mutant-nftengine\moralis-mutants-nft-engine\node_modules\axios\lib\adapters\http.js:293:11)
at IncomingMessage.emit (node:events:539:35)
at endReadableNT (node:internal/streams/readable:1345:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},

maybe you donā€™t have to add " here?

1 Like

thank you! here was the error
i was using the wrong API_url
ā€œhttps://deep-index.moralis.io/api-docs/#/storage/uploadFolderā€
i have change it to
API_URL=ā€œhttps://deep-index.moralis.io/api/v2/ipfs/uploadFolderā€

1 Like

@cryptokid having the same issue here, i keep getting this error (screenshot attached)

Code is the following

import "../styles/globals.css";
import type { AppProps } from "next/app";
import { MoralisProvider } from "react-moralis";
import { MoralisDappProvider } from "../src/providers/MoralisDappProvider/MoralisDappProvider";

const APP_ID = "9mCJLhebtIbRti9XL8oVscBPIlCL6EBeFbrkoL7E";
const SERVER_URL = "https://xvebvq4ftwkf.usemoralis.com:2053/server";

function Example({ Component, pageProps }: AppProps) {
  const isServerInfo = APP_ID && SERVER_URL ? true : false;
  //validate
  if (!APP_ID || !SERVER_URL)
    throw new Error(
      "Missing Moralis Application ID and or SERVER URL. Make sure to set your .env file."
    );
  if (isServerInfo)
    return (
      <MoralisProvider
        appId={APP_ID}
        serverUrl={SERVER_URL}
        initializeOnMount={true}
      >
        <MoralisDappProvider>
          <Component isServerInfo {...pageProps} />
        </MoralisDappProvider>
      </MoralisProvider>
    );
}
export default Example;

appreciate your help!

this is all the code that you have?

1 Like

no i have a few pages and Components in a next app.

This is index.tsx:

import type { NextPage } from "next";
import Head from "next/head";
import { useMoralis } from "react-moralis";
import Header from "../src/components/Header/Header";
import Login from "../src/components/Login/Login";
const Home: NextPage = () => {
  const { isAuthenticated } = useMoralis();

  if (!isAuthenticated) return <Login />;
  return (
    <div className="flex min-h-screen flex-col">
      <Head>
        <title>IT</title>
        <link rel="icon" href="/favicon.ico" />
      </Head>
      <Header />
    </div>
  );
};

export default Home;

all of a sudden it works again!

1 Like

Getting the same issue on saving in one particular class, in others classes it is working fine but for that one particular classs it is throwing

Access to XMLHttpRequest at 'https://xxxxx.grandmoralis.com:2053/server/functions/saveLotItemDataā€™ from origin ā€˜http://localhost:3000ā€™ has been blocked by CORS policy: No ā€˜Access-Control-Allow-Originā€™ header is present on the requested resource.

that looks like a moralis server url, is the server working? can you access that url directly?

you can also get that error when the server is not able to respond in time