Back

[SOLVED] Error: getaddrinfo ENOTFOUND hostname

  • 1
  • Functions
  • Web
Sandeep
18 Feb, 2023, 08:04

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"

TL;DR
The user encountered an error 'getaddrinfo ENOTFOUND hostname' while using Node.js Cloud Functions with Appwrite. They initially didn't have the execution roles set properly, but after correcting it, they were still facing the issue. Another user suggests checking if the correct endpoint was passed to `client.setEndpoint()`. The user confirms they created the function using the CLI and passed the correct endpoint, but they still receive an 'Error: connect ECONNREFUSED 127.0.0.1:80' when trying to write data to the database. There is no solution provided in the thread.
Sandeep
18 Feb, 2023, 08:29

Error: connect ECONNREFUSED 127.0.0.1:80

Sandeep
18 Feb, 2023, 08:43

Error: getaddrinfo ENOTFOUND hostname

Drake
18 Feb, 2023, 08:44

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

Sandeep
18 Feb, 2023, 08:45

Yes, I created the function using CLI appwrite init function

Drake
18 Feb, 2023, 08:45

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

Sandeep
18 Feb, 2023, 08:47

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);

Drake
18 Feb, 2023, 08:47

So did you create the variable with the correct value?

Sandeep
18 Feb, 2023, 08:54

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

Drake
18 Feb, 2023, 08:56

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

Sandeep
18 Feb, 2023, 08:58

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

Drake
18 Feb, 2023, 09:00
Sandeep
18 Feb, 2023, 09:25

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

Sandeep
18 Feb, 2023, 09:29

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

Drake
18 Feb, 2023, 15:27

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

Drake
23 Feb, 2023, 21:05

[SOLVED] Error: getaddrinfo ENOTFOUND hostname

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more