Unable to connect to local ceramic node

I was trying to use composedb. For that i need the ceramic node running. I run it but the code is unable to connect to it. When i open localhost:7007 on browser it connects without any issues, but from my express server i try to connect to it I get connection refused.

I am on macos.

1 Like

Just a sanity check, is your express server using a get or a post request to try & reach the server?

This is my code

const did = new DID({
    resolver: getResolver(),
    provider: new Ed25519Provider(privateKey),
  await did.authenticate();

  // Replace by the URL of the Ceramic node you want to deploy the Models to
  const ceramic = new CeramicClient("http://localhost:7007");
  // An authenticated DID with admin access must be set on the Ceramic instance
  ceramic.did = did;
  console.log("Ceramic instance created");
  // Replace by the path to the local encoded composite file
  const composite = await readEncodedComposite(ceramic, "composite.json");
  console.log("Composite read");
  // Notify the Ceramic node to index the models present in the composite
  await composite.startIndexingOn(ceramic);

I see logs till “Ceramic instance created” then it fails on the next line “readEncodedComposite”
I have composite.json file on the root directory

Can you wrap const composite... in a try catch & let me know the error you’re getting?

FetchError: request to http://localhost:7007/api/v0/streams failed, reason: connect ECONNREFUSED ::1:7007

I know for sure my node is running, http://localhost:7007/ opens on my browser indicating the server is running and receiving my request.

What does the page look like? If it has anything beyond a cannot get / that’s likely the problem. Ceramic nodes only allows for post requests.

It shows cannot get / only

Last sanity check for me, if you use Create Ceramic App to create an app can it access your node (just use npx @ceramicnetwork/create-ceramic-app clone & choose the ComposeDB template. Please be sure to npm install before running npm run dev.

I solved it, had to change http://localhost:7007 to when using it on backend on frontend localhost works