Search code examples
pythondockergraphqlprefect

Cant Access Prefect Server Remotely


I used the command prefect server start --postgres-port=5433 --server-port=5001 --hasura-port=5002 --graphql-port=5003 --expose to start prefect server at the allowed ports in my azure network. And when i do a docker ps i get

CONTAINER ID   IMAGE                          COMMAND                  CREATED          STATUS                    PORTS                                   NAMES
873bfa5bd6bc   prefecthq/ui:core-0.15.7       "/docker-entrypoint.…"   23 minutes ago   Up 23 minutes (healthy)   80/tcp, 0.0.0.0:8080->8080/tcp          tmp_ui_1
9ca79a768265   prefecthq/apollo:core-0.15.7   "tini -g -- bash -c …"   23 minutes ago   Up 23 minutes (healthy)   0.0.0.0:5003->4200/tcp                  tmp_apollo_1
ab7c87ddbabb   prefecthq/server:core-0.15.7   "tini -g -- python s…"   23 minutes ago   Up 23 minutes                                                     tmp_towel_1
ef230baeddb5   prefecthq/server:core-0.15.7   "tini -g -- bash -c …"   23 minutes ago   Up 23 minutes (healthy)   127.0.0.1:5001->4201/tcp                tmp_graphql_1
410c38f08f83   hasura/graphql-engine:v1.3.3   "graphql-engine serve"   23 minutes ago   Up 23 minutes (healthy)   127.0.0.1:5002->3000/tcp                tmp_hasura_1
82748fbc9f4d   postgres:11                    "docker-entrypoint.s…"   23 minutes ago   Up 23 minutes (healthy)   127.0.0.1:5433->5432/tcp                tmp_postgres_1

my ~/.prefect/config.toml is

[server]
  endpoint = "http://ipaddress:5003/graphql"

  [server.ui]
  apollo_url = "http://ipaddress:5003/graphql"

Then as i start the server the status goes as in figure and redirects to ipaddress:8080/getting-started page enter image description here

I checked the logs of the tmp_towel_1 using docker logs ab7c87ddbabb as it wasnt showing healthy status, where i found out a few errors

[Errno 111] Connect call failed ('some_ipaddress_which_i_dont_know_about', 3000)"}

i suppose it is docker network ip or something. have no clue. Can anyone suggest where i might be wrong?


Solution

  • The same issue was posted via community Slack and based on a discussion there we figured that the solution is to set the port using --server-port and not expose other ports since those are used only internally between individual components. So the command below should work:

    prefect server start --server-port=5003 --no-postgres-port --use-volume --expose
    

    And then within the config.toml, use:

    [server]
    endpoint = "http://YOUR_MACHINES_PUBLIC_IP:5003/graphql"
    
      [server.ui]
        apollo_url = "http://YOUR_MACHINES_PUBLIC_IP:5003/graphql"
    
    

    Sharing this here for posterity.