
I have hosted appwrite on DigitalOcean. I'm using Node.js Cloud Functions to write some data to the database. But, I'm unable to do it as it throws errror Error: connect ECONNREFUSED 127.0.0.1:80"

Error: connect ECONNREFUSED 127.0.0.1:80

Error: getaddrinfo ENOTFOUND hostname

Did you pass the correct endpoint to client.setEndpoint()
?

Yes, I created the function using CLI appwrite init function

That doesn't necessarily mean you're passing the correct endpoint

client
.setEndpoint(req.variables["APPWRITE_FUNCTION_ENDPOINT"])
.setProject(req.variables["APPWRITE_FUNCTION_PROJECT_ID"])
.setKey(req.variables["APPWRITE_FUNCTION_API_KEY"])
.setKey(req.variables["SIGNUP_KEY"])
.setSelfSigned(true);

So did you create the variable with the correct value?

I think, I have misunderstood that SDK provides the variables. Am I right?

Nope. The are the only built in variables: https://appwrite.io/docs/functions#functionVariables

Cool. I have inspected them. So, now I understood that we provide the endpoint. How can we know it?

Maybe this will help? https://appwrite.io/docs/getting-started-for-server

Thank you very much man. I resolved it after passing correct ENDPOINT.

One question, when I redeploy the function, the roles are missing. I need to set it everytime. Can I know the reason?

Did you add the execution roles to your appwrite.json?

[SOLVED] Error: getaddrinfo ENOTFOUND hostname
Recommended threads
- Sharing cookies
Hi, I’m using Appwrite Cloud, and I have a setup where my Appwrite backend is hosted on a subdomain (e.g., api.example.com), while my frontend (Next.js app) and...
- Organization not exists anymore
Hello! We have a problem with a cloud database. We are on the Free plan, but after a refresh the site wants me to create a new organisation, and I not see the c...
- JSON and Object Support in Collection do...
I am working with Next.Js and Appwrite Cloud, I am relatively New to Appwrite but i have noticed there is no direct support of JSON and Object support in attrib...
