Thread
#prefect-community
    Shivam Bhatia

    Shivam Bhatia

    2 months ago
    Hi, I am trying to self host prefect 2.0 on a gcp cloud engine vm. I have installed prefect on the vm and set PREFECT_API_URL as "httpšŸ˜•/<external-ip>:4200/api" I tried to connect to the prefect instance from my local machine by setting the PREFECT_API_URL on my machine and running this code:
    $ # start python REPL with native await functionality
    $ python -m asyncio
    >>> from prefect.client import get_client
    >>> async with get_client() as client:
    ...     response = await client.hello()
    ...     print(response.json())
    šŸ‘‹
    and I got this error:
    Traceback (most recent call last):
      File "/usr/lib/python3.9/concurrent/futures/_base.py", line 440, in result
        return self.__get_result()
      File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
        raise self._exception
      File "<console>", line 1, in <module>
      File "/home/shivam/.local/lib/python3.9/site-packages/prefect/client.py", line 111, in get_client
        ctx = prefect.context.get_settings_context()
      File "/home/shivam/.local/lib/python3.9/site-packages/prefect/context.py", line 272, in get_settings_context
        raise MissingContextError("No settings context found.")
    prefect.exceptions.MissingContextError: No settings context found.
    Am I missing something in the setup?
    Mathijs Carlu

    Mathijs Carlu

    2 months ago
    Did you set PREFECT_API_URL by executing
    prefect config set PREFECT_API_URL="http://<external-ip>:4200/api"
    ?
    Shivam Bhatia

    Shivam Bhatia

    2 months ago
    Yes, on my local machine
    Mathijs Carlu

    Mathijs Carlu

    2 months ago
    what is the output of
    prefect config view
    ?
    Shivam Bhatia

    Shivam Bhatia

    2 months ago
    PREFECT_PROFILE='default'
    PREFECT_API_URL='http://<external-ip>:4200/api' (from profile)
    Mathijs Carlu

    Mathijs Carlu

    2 months ago
    Was able to recreate the issue on Windows. I think there might still be some bugs on Windows, as there was initially no support. Instead of
    get_client()
    , you could use
    OrionClient('http://<external-ip>:4200/api')
    . This seems to work on my machine
    Anna Geller

    Anna Geller

    2 months ago
    I don't know how to help here - can you perhaps try Cloud 2.0 first before self-hosting? this guide will help you get started https://discourse.prefect.io/t/how-to-get-started-with-prefect-cloud-2-0/539
    Mathijs Carlu

    Mathijs Carlu

    2 months ago
    @Anna Geller the problem seems to be that the settings_context cannot be found when running
    python -m asyncio
    from the terminal. I was able to recreate on both windows and linux
    Anna Geller

    Anna Geller

    2 months ago
    if you believe there is a bug here, please open a GitHub issue here https://github.com/PrefectHQ/prefect/issues/new/choose and choose 2.0