rpeden / prefect-docker-compose

A repository that makes it easy to get up and running with Prefect 2 using Docker Compose.
117 stars 24 forks source link

My prefect UI can not connect to Can't connect to http://0.0.0.0:4200/api #1

Closed seabnavin19 closed 1 year ago

seabnavin19 commented 2 years ago

When I try to run the first command

docker-compose --profile orion up

I got this erorr in my ui http://localhost:4200/runs

Can't connect to Orion API at http://0.0.0.0:4200/api. Check that it's accessible from your machine.

even I run the second command

docker-compose run cli

and run python flow.py I still get the same erorr, How can I make my UI access to my flow run?

chris-aeviator commented 2 years ago

facing the same issue when deploying on host thats not local (remote server)

seabnavin19 commented 2 years ago

I have solve this by changing the API URL:

orion:
    image: prefecthq/prefect:2.4.2-python3.10
    restart: always
    volumes:
      - prefect:/root/.prefect
    entrypoint: ["prefect", "orion", "start"]
    environment:
      - PREFECT_ORION_API_HOST=0.0.0.0
      - PREFECT_ORION_DATABASE_CONNECTION_URL=postgresql+asyncpg://postgres:postgres@database:5432/orion
      - PREFECT_API_URL= <your remote server public IP> or localhost(if running in local)
    ports:
      - 4200:4200
    depends_on:
      - database
    profiles: ["orion"]

  ## Prefect Agent
  agent:
    image: prefecthq/prefect:2.4.2-python3.10
    restart: always
    entrypoint: ["prefect", "agent", "start", "-q", "YOUR_WORK_QUEUE_NAME"]
    environment:
      - PREFECT_API_URL= <your remote server public IP> or localhost(if running in local)
#       Use PREFECT_API_KEY if connecting the agent to Prefect Cloud
#     - PREFECT_API_KEY=YOUR_API_KEY
    profiles: ["agent"]
rpeden commented 2 years ago

Thanks for the update, Sean. I'll add a section about this to the README. Apologies for not responding sooner - my GitHub notifications were going to spam folder.

seabnavin19 commented 2 years ago

Ok, btw your repo is a good resource thanks you

endbro commented 1 year ago

Having the same problems as OP on a Win 10 corp issued laptop today when testing this locally. When testing at home on a Mac I had no such issue.

Just an observation.

Edit:

Did simple test on a non-corp set up win 10 pro machine also

  1. clone this repo
  2. docker-compose --profile server up
  3. open "http://localhost:4200" in browser. Redirected to "http://localhost:4200/flow-runs"
  4. msg "Can't connect to Server API at http://0.0.0.0:4200/api. Check that it's accessible from your machine." shows up soon at bottom right of page.
rpeden commented 1 year ago

Thanks for the update - I reopened the issue and will give this a try on Windows to see if I can reproduce and fix it.

tomasrollo commented 1 year ago

I just had the same issue on Mac, fixed by setting PREFECT_API_URL=http://127.0.0.1:4200/api in the server part of the docker-compose.yml file.

rpeden commented 1 year ago

I just had the same issue on Mac, fixed by setting PREFECT_API_URL=http://127.0.0.1:4200/api in the server part of the docker-compose.yml file.

Good thinking. I added that to the Docker Compose file.