Skip to content
Init is here / May 19 - 23
Back

[Solved] Error: Appwrite-executor with status code 0

  • 0
  • Self Hosted
Binho.dev πŸ’™
20 Jul, 2023, 13:05

Hi πŸ‘‹

After deploy a function, got this error: Could not resolve host: appwrite-executor with status code 0.

TL;DR
User was getting an error "Could not resolve host: appwrite-executor with status code 0" after deploying a function in the Appwrite dashboard. The user shared their code that sets the endpoint and variables. The value for the variable "APPWRITE_FUNCTION_ENDPOINT" was shared as well. The user confirmed that they are using a self-hosted Appwrite and shared the output of the `docker ps -a` command. It was discovered that the `appwrite-executor` container was recently created. The user was asked to try executing the function again, but it was still not working. The user then mentioned that they recently made
Binyamin
20 Jul, 2023, 13:11

Where you getting this error exactly?

Binho.dev πŸ’™
20 Jul, 2023, 13:11

In dashboard...

Binho.dev πŸ’™
20 Jul, 2023, 13:12
Binyamin
20 Jul, 2023, 13:12

πŸ‘

Binyamin
20 Jul, 2023, 13:13

Can you share this part of your code

TypeScript
const client = new Client()
    .setEndpoint('https://cloud.appwrite.io/v1') 
Binho.dev πŸ’™
20 Jul, 2023, 13:13

OK

Binho.dev πŸ’™
20 Jul, 2023, 13:13

Hmm..

Binho.dev πŸ’™
20 Jul, 2023, 13:14
TypeScript
import * as sdk from "node-appwrite";

type AppwriteVariables =
  | "APPWRITE_FUNCTION_ENDPOINT"
  | "APPWRITE_FUNCTION_API_KEY"
  | "APPWRITE_FUNCTION_ID"
  | "APPWRITE_FUNCTION_PROJECT_ID"
  | "APPWRITE_FUNCTION_API_KEY";

type AppwriteRequest = {
  headers: { [name: string]: string };
  payload: string;
  variables: { [key in AppwriteVariables]: string };
};

interface AppwriteResponse {
  send: (data: string, status?: number) => {};
  json: (data: object, status?: number) => {};
}

module.exports = async function (req: AppwriteRequest, res: AppwriteResponse) {
  const client = new sdk.Client();
  const users = new sdk.Users(client);

  if (
    !req.variables["APPWRITE_FUNCTION_ENDPOINT"] ||
    !req.variables["APPWRITE_FUNCTION_API_KEY"]
  ) {
    throw Error(
      "Environment variables are not set. Function cannot use Appwrite SDK."
    );
  } else {
    client
      .setEndpoint(req.variables["APPWRITE_FUNCTION_ENDPOINT"])
      .setProject(req.variables["APPWRITE_FUNCTION_PROJECT_ID"])
      .setKey(req.variables["APPWRITE_FUNCTION_API_KEY"])
      .setSelfSigned(true);
  }

  const getAllUsers = await users.list();

  res.json({ message: getAllUsers.users });
};
Binho.dev πŸ’™
20 Jul, 2023, 13:15

I have set variables in functions settings (dashboad)

Binyamin
20 Jul, 2023, 13:16

That seems good

Binyamin
20 Jul, 2023, 13:16

And what value you've put inside this variable? APPWRITE_FUNCTION_ENDPOINT

Binho.dev πŸ’™
20 Jul, 2023, 13:17
Binho.dev πŸ’™
20 Jul, 2023, 13:19

When try activate i got this error

Binho.dev πŸ’™
20 Jul, 2023, 13:19
Binyamin
20 Jul, 2023, 13:28

Is this a self-hosted Appwrite?

Binho.dev πŸ’™
20 Jul, 2023, 13:29

Yes

Binyamin
20 Jul, 2023, 13:30

Can you run

TypeScript
docker ps -a

And share the results?

Binho.dev πŸ’™
20 Jul, 2023, 13:30

ok

Binho.dev πŸ’™
20 Jul, 2023, 13:31
Binho.dev πŸ’™
20 Jul, 2023, 13:33

Up 2 minutes ago beacuse updated .env file, added a dart runtimes

Binyamin
20 Jul, 2023, 13:39

Okay so it seems like the appwrite-executor has just been created Can you try to execute your function now

Binyamin
20 Jul, 2023, 13:39

It seems like it should work

Binho.dev πŸ’™
20 Jul, 2023, 14:02

Don’t work

Binho.dev πŸ’™
20 Jul, 2023, 14:03

Before this didn’t work, I changed the .env file because I had forgotten to add the runtime, but I tell you that it was no longer working.

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