https://prefect.io logo
Title
v

Vlad Tudor

09/01/2022, 2:09 PM
Please help a person in despair Hello, I'm trying to setup Prefect inside a
docker-compose
that runs on a remote VM. However, I cannot configure the correct URL for the
graphql
(when opening the UI, I get the error
Couldn't connect to Prefect Server at <http://localhost:4200/graphql>
) I tried to configure it from the
config.toml
file with the URL of my machine:
[server]
  [server.ui]
    graphql_url = "http://<<MACHINE_PUBLIC_IP>>:4200/graphql"
but it still tries the access localhost. Any help will be thoroughly appreciated. It's been 12 hours..
βœ… 1
1️⃣ 1
r

Ryan Peden

09/01/2022, 2:16 PM
Hi Vlad, what does your Docker Compose service for Prefect look like in your
docker-compose.yml
file?
πŸ‘€ 1
j

Jeff Hale

09/01/2022, 2:16 PM
Sorry to hear that. Please don’t despair. πŸ™‚ Is this guide helpful?
❀️ 1
v

Vlad Tudor

09/01/2022, 2:18 PM
@Jeff Hale I've been using that already πŸ˜„
This is the
docker-compose
service:
ui:
    command: /intercept.sh
    depends_on:
      apollo:
        condition: service_healthy
    volumes:
      - type: bind
        source: ./config.toml
        target: /root/.prefect/config.toml
        read_only: true
    healthcheck:
      interval: 30s
      retries: 3
      test: curl --fail --silent --head "<http://ui:4001/>" &> /dev/null || exit 1
      timeout: 5s
    image: prefecthq/ui:core-1.2.2
    ports:
      - 4001:8080
    restart: always
    networks:
      - prefect-server
Now I question wether it's the correct wai to pass the
config.toml
I'd prefer using environment variables but resources online are conflicting on the names of the variables
I now tried setting
PREFECT__SERVER__UI__GRAPHQL_URL
(but also
PREFECT_SERVER__UI__GRAPHQL_URL
) as env variables but still the UI check localhost
r

Ryan Peden

09/01/2022, 2:24 PM
does the
apollo
service in the Docker Compose yaml still have:
ports:
      - 4200:4200/tcp
v

Vlad Tudor

09/01/2022, 2:26 PM
@Ryan PedenYes, moreover I can check that the port configuration is not correctly passed by looking at the calls the UI makes, and they are still on localhost
r

Ryan Peden

09/01/2022, 2:26 PM
To make sure I'm understanding correctly - you want the UI to contact the server's IP instead of
localhost
?
v

Vlad Tudor

09/01/2022, 2:27 PM
Yes, and I am not sure how to configure a non-default URL for graphql
In some resources I find:
[server]
  [server.ui]
    apollo_url = "<http://YOUR_MACHINES_PUBLIC_IP:4200/graphql>"
In others:
[server]
  [server.ui]
    graphql_url = "<http://YOUR_MACHINES_PUBLIC_IP:4200/graphql>"
r

Ryan Peden

09/01/2022, 2:39 PM
In this pull request, it looks like an option was added to set a
PREFECT_SERVER__APOLLO_URL
environment variable. You may need to run
localStorage.clear()
in your browser's console afterward because it might have the old URL cached
v

Vlad Tudor

09/01/2022, 2:45 PM
Seems like
PREFECT_SERVER__APOLLO_URL
woks but indeed, it's crucial to clear the cache of the browser. Gee that was a headache πŸ˜„ Thank you so much kind sir
Now I have simmilar issues when trying to connect the client to the Server πŸ™ƒ
PREFECT__SERVER__HOST: <http://apollo>
      PREFECT__SERVER__PORT: 4200
In the environment variables I should also replace apollo with my machine IP?
r

Ryan Peden

09/01/2022, 3:14 PM
yes, I believe so -
<http://apollo>
will only work if the client container is connected to the same Docker network as the server container
v

Vlad Tudor

09/01/2022, 3:20 PM
In this case, it is in the same network (and still doesn't seem to work as no agents and projects appear in the ui) If I configure
PREFECT__SERVER__HOST: http://<<MACHINE_IP>>
      PREFECT__SERVER__PORT: 4200
I get
ConnectionTimedOut
πŸ₯²
r

Ryan Peden

09/01/2022, 4:01 PM
If you are using the client example from the repo Jeff linked above, did you change
host
in
config.toml
? When I set the host there, it works whether I use
apollo
or the server IP as the host
v

Vlad Tudor

09/01/2022, 4:07 PM
not really, it keeps loading πŸ˜• In the logs I see the
<http://44.205.14.8:4001/>
error
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='3.205.14.8', port=4200): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f98064740d0>
r

Ryan Peden

09/01/2022, 4:15 PM
Is
3.205.14.8
the IP of the server where you used docker compose to run the server?
v

Vlad Tudor

09/01/2022, 4:16 PM
yes
It does not fail if I pass
<http://172.17.0.1>
but neither does it work
I mean, in the logs I see that the Gaent is created but I guess it is rregistred to a different database as it does not appear in the UI
@Ryan Peden Do I need to set up any other URL? for example
PREFECT__API__URL=<http://postgres:5432>
?
In the logs I see that the flow is registred as
<http://localhost:8080/default/flow/5957343a-9867-430d-b2f9-053cf764d57d>
, so this is not good, right?
r

Ryan Peden

09/01/2022, 4:45 PM
I think that is okay. I see the same thing but the flow still shows up in my UI as expected
v

Vlad Tudor

09/01/2022, 4:47 PM
do you run on your local device? I did not have these issues also while running locally
P.S I also run things through an nginx, do you think it can cause the issue?
r

Ryan Peden

09/01/2022, 4:55 PM
I believe so. It depends on how nginx is configured, which ports it is set up to receive connections on and forward to other services, etc. That is more a network/nginx config issue though, so it's beyond the scope of what I diagnose/troubleshoot
v

Vlad Tudor

09/01/2022, 5:07 PM
Either way, tahnk you for your patience. If I find the solution I'll post it here
r

Ryan Peden

09/01/2022, 5:11 PM
Thanks, Vlad. I appreciate that. And I'm happy to help. Anything you find would be helpful. Eventually, I would like to create a tutorial on running Prefect using Docker Compose a Nginx...and although I focus mostly on Prefect 2 and not Prefect 1, I suspect that anything Nginx + docker-compose related will be applicable to both.
v

Vlad Tudor

09/02/2022, 7:04 AM
I think I got over some problems with nginx. But I still think I'm missing some Prefect configuration. For the client service in
docker-compose
I set:
- PREFECT__SERVER__ENDPOINT=<http://apollo:4200>
      - PREFECT__SERVER__UI__ENDPOINT=<http://ui:8080>
and when the flow is registred it's registred at:
<http://ui:8080/default/flow/1dbc36f7-4302-458c-a8cd-e436a93142cb>
but from the UI I cannot access it. My question is, what URL should I set. Should I set the IP of the remote machine? @Ryan Peden What do you think?