Back

[SOLVED] How to properly setup Appwrite on localhost for cloud functions ?

  • 3
  • Functions
squallsama
9 Apr, 2023, 06:10

Function failed in Appwrite Console due to timeout and in logs it's connection refused

TL;DR
Issue: Setting up Appwrite on localhost for cloud functions Solution: 1. Use `host.docker.internal` as the value for the endpoint. 2. If using a local machine, use the LAN IP or `host.docker.internal`. 3. Make sure the docker networks are properly set up. 4. Check the folder name of the docker-compose.yml file. 5. Connect to the runtime container and run the curl command to check for connection issues. 6. If experiencing connection refused errors, check the executor container logs for further details. 7. If the function fails in the Appwrite Console due to timeout, check the logs for connection
squallsama
9 Apr, 2023, 06:10
squallsama
9 Apr, 2023, 06:10
Drake
9 Apr, 2023, 06:12

Okay. It's connection refused

squallsama
9 Apr, 2023, 06:12

yep

squallsama
9 Apr, 2023, 06:12

[Error] Type: Exception [Error] Message: An internal curl error has occurred within the executor! Error Msg: Connection refused [Error] File: /usr/src/code/app/executor.php [Error] Line: 541

squallsama
9 Apr, 2023, 06:13

in appwrite/appwrite:1.2.1 "executor" container logs

Drake
9 Apr, 2023, 06:13

Can you try exec'ing into the runtime container and running

TypeScript
curl -H "X-Internal-Challenge: secret-key" -H "Content-Type: application/json" -X POST http://localhost:3000/ -d '{"payload":"{}"}'`
squallsama
9 Apr, 2023, 06:16

you mean docker exec -it 3cbb50225f46 /bin/sh and execute your command ?

squallsama
9 Apr, 2023, 06:17
Drake
9 Apr, 2023, 06:18

That's expected because we don't know the internal challenge but at least we can connect to it.

Drake
9 Apr, 2023, 06:18

What's the name of the folder your docker-compose.yml is in?

squallsama
9 Apr, 2023, 06:19

project_dir/appwrite/deployment/

squallsama
9 Apr, 2023, 06:19

not sure it's matter, because on VM with domain name + ssl everything works fine and this issue is only appears on localhost....

Drake
9 Apr, 2023, 06:19

Can you (docker) inspect the runtime container and the executor containers and look to see what docker networks they're in?

squallsama
9 Apr, 2023, 06:38

yeah, networks in docker were messed up. Sorry for bothering 😦

Drake
9 Apr, 2023, 06:48

No worries. So problem is resolved now?

squallsama
9 Apr, 2023, 06:49

With template function, yes. Now I'm trying to understand what value should I use for APPWRITE_FUNCTION_ENDPOINT to be able to set-up Appwrite client in function

squallsama
9 Apr, 2023, 06:51
squallsama
9 Apr, 2023, 06:52

using http://192.168.0.143/v1 or either http://localhost/v1

Drake
9 Apr, 2023, 06:53

If you're on a local machine, you typically use your LAN IP. I've also gotten host.docker.internal to work too

squallsama
9 Apr, 2023, 06:53
squallsama
9 Apr, 2023, 06:53

I'l try host.docker.internal

squallsama
9 Apr, 2023, 06:54

host.docker.internal - works perfect. Thanks πŸ™‚

Tessa
11 Apr, 2023, 22:25

[SOLVED] How to properly setup Appwrite on localhost for cloud functions ?

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