Skip to content
Back

ClientException with SocketException: Cloud Functions 500 Status Codes

  • 0
  • 3
  • Functions
  • Cloud
Mj
11 Apr, 2026, 08:00

hi @eldad i have noticed this 500 status code in my function requests, it seems its not able to connect to the internet in the function as requests to APIs and urls fail with ClientException with SocketException: failed host lookup: ... (OS Error: name or service not known, errno = -2)

i also get this error which is basically same thing:

TypeScript
Error: Exception: Invalid or expired token.
Unhandled error: Exception: Invalid or expired token.``` 


Note that this happens like twice in every 10 request.
TL;DR
Issue: ClientException with SocketException occurs in Cloud Functions with 500 Status Codes affecting the app. Solution: The problem seems to be with the function environment not resolving domain names to IP addresses. Update the runtime, check if it works locally, and have engineers debug the network. Additionally, check the specific functions that are throwing the error and share more information for further assistance.
Arhan Ansari
11 Apr, 2026, 08:01

Better not to tag eldad directly....

eldad
11 Apr, 2026, 08:02

all good I asked 👍

eldad
11 Apr, 2026, 08:02

please share the code, project ID, runtime, region etc

Mj
11 Apr, 2026, 08:55

status code 500, project id: 6751d496002a1bcc7486, dart runtime, FRA region

Mj
11 Apr, 2026, 08:58

Error is always ClientException with SocketException: Failed host lookup:, wether its appwrite services or doing a HTTP request to external URLs in the function, it gives that error. it's happening more frequently now.

11 Apr, 2026, 10:52

<@564158268319203348>

11 Apr, 2026, 11:01

Share the code

11 Apr, 2026, 11:20

Here is the code:

TypeScript
        final response = await _client.get(
          Uri.parse('$baseUrl/account/balance'),
          headers: {'Authorization': 'Bearer $key'},
        );
        print(
            'balance check for ${key.substring(0, 5)}: status=${response.statusCode}');

you get this response when it happens: balance check error for sk_0z: ClientException with SocketException: Failed host lookup: '{the uri here}' (OS Error: Name or service not known, errno = -2), uri={the uri here}

Note: i omitted the host lookup/uri value for privacy in the response,

11 Apr, 2026, 11:29

if you need to know what the _client is, its just an http client http.Client()

11 Apr, 2026, 11:33

Is your function execution throwing this or the function code? This doesn’t look like any valid Appwrite authentication. Appwrite doesn’t use the Authorization header

11 Apr, 2026, 12:04

the code inside the function us throwing this.

11 Apr, 2026, 12:06

even appwrite specific code inside the function also throws this, like the error i shared in the first message

11 Apr, 2026, 19:49

Have this been looked into?

This is literally still happening and still affecting my app!!

Authentication failed: Exception: Failed to fetch user: AppwriteException: , ClientException with SocketException: Failed host lookup: 'fra.cloud.appwrite.io' (OS Error: Name or service not known, errno = -2), uri=https://fra.cloud.appwrite.io/v1/account?# (0)

ClientException with SocketException: Failed host lookup: 'https://cloud.blackbox.ai' (OS Error: Name or service not known, errno = -2), uri=https://cloud.blackbox.ai/api/tasks

Seems like the function environment literally cannot resolve the domain name to an IP address.

11 Apr, 2026, 20:30

which of your functions is throwing this?

11 Apr, 2026, 20:30

does it work locally?

11 Apr, 2026, 20:35

Once I can tell which function is it running it will be easier for our engineers to debug the network of its runtime

11 Apr, 2026, 20:41

this function 675f5e0d00091e698d30 is throwing it. i have just updated the runtime from dart 3.5 to dart 3.11 in hopes that it will fix this issue

11 Apr, 2026, 20:53

this function too: imgflux_gen_v2_id

11 Apr, 2026, 21:38

<@564158268319203348> are they on it?

12 Apr, 2026, 19:18

I made sure someone from engineering will look into it when they start work

1
13 Apr, 2026, 02:13
13 Apr, 2026, 05:56

500 error is very generic. Do you get same SocketException? please share more information.

13 Apr, 2026, 06:25
13 Apr, 2026, 06:25

this error sir

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