
I'm in a local environment and when try to execute a python function, it give me this error.
TypeScript
HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: /v1/users/64da4dd537130292e7ad (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffffa86be0d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
The code of the function:
TypeScript
import json
from appwrite.client import Client
from appwrite.services.databases import Databases
from appwrite.services.users import Users
from appwrite.id import ID
from appwrite.services.teams import Teams
def main(req, res):
# Environment variables
payload = json.loads(req.variables.get('APPWRITE_FUNCTION_EVENT_DATA'))
endpoint = req.variables.get("APPWRITE_ENDPOINT")
project_id = req.variables.get("APPWRITE_PROJECT_ID")
api_key = req.variables.get("APPWRITE_API_KEY")
database_id = req.variables.get('DATABASE_ID')
users_collection_id = req.variables.get('USERS_COLLECTION_ID')
# Setup client
client = Client()
client.set_endpoint(endpoint).set_project(project_id).set_key(api_key)
# Setup Databases
database = Databases(client=client)
# Setup Users
user = Users(client=client)
try:
database.get_document(database_id, users_collection_id, payload['userId'])
except Exception:
try:
user_data = json.loads(user.get(payload['userId']))
print(user_data)
database.create_document(
database_id=database_id,
collection_id=users_collection_id,
document_id=payload['userId'],
data={
'userId':payload['userId'],
'name':user_data['name'],
'email':user_data['email'],
}
)
except Exception as e:
print(str(e))
TL;DR
The user is experiencing an error `HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: /v1/users/64da4dd537130292e7ad (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffffa86be0d0>: Failed to establish a new connection: [Errno 111] Connection refused'))` when trying to execute a Python function in a local environment.
A possible solution to this issue can be found in this forum thread: <https://github.com/appwrite/appwrite/discussions/3917#discussioncomment-372030
Maybe this will help: https://github.com/appwrite/appwrite/discussions/3917#discussioncomment-3720307

Ah, I didn't know, thank you!
Recommended threads
- Attribute already exists in schema
I created an attribute, deleted it and now I can't create it again. It says "Failed" and "Attribute already exists in schema". ```json { "27": { "ke...
- Decentralisation
I had queries regarding decentralisation with self hosting, particularly with sites as a recent addition. Can we decentralise sites as in many cases we would li...
- Error response from daemon: driver faile...
on endpoint appwrite-traefik (00bbc10e5875d0c367d8975c6abc946a77b7ec201a64a825399add44fb34ebb4): failed to bind port 0.0.0.0:80/tcp: Error starting userland pro...
