<@ULVA73B9P> I ran docker compose file for prefect...
# ask-marvin
v
@Marvin I ran docker compose file for prefect server as per the documentation but failed to load the prefect ui after running the compose file with error Can't connect to Server API at http://0.0.0.0:4200/api.
m
thought for 159.7 seconds
Thanks for the details — that specific error means the UI is trying to call the API at 0.0.0.0, which is only a bind address inside the container and not reachable from your browser. What’s happening - When
PREFECT_UI_API_URL
is not set, the UI builds its API URL from
PREFECT_SERVER_API_HOST
and
PREFECT_SERVER_API_PORT
. - With
PREFECT_SERVER_API_HOST=0.0.0.0
, the UI ends up trying to hit
<http://0.0.0.0:4200/api>
from your browser, which fails. Fix - Set
PREFECT_UI_API_URL
to an address your browser can reach: - If you’re running Docker locally and visiting from the same machine:
<http://localhost:4200/api>
- If you’re on a remote VM:
http://<your-hostname-or-ip>:4200/api
Update your docker-compose for the server container like this:
Copy code
services:
  prefect-server:
    image: prefecthq/prefect:3-latest
    environment:
      PREFECT_API_DATABASE_CONNECTION_URL: <postgresql+asyncpg://prefect:prefect@postgres:5432/prefect>
      PREFECT_SERVER_API_HOST: 0.0.0.0
      PREFECT_UI_API_URL: <http://localhost:4200/api>   # or http://<host>:4200/api if remote
      PREFECT_MESSAGING_BROKER: prefect_redis.messaging
      PREFECT_MESSAGING_CACHE: prefect_redis.messaging
      PREFECT_REDIS_MESSAGING_HOST: redis
      PREFECT_REDIS_MESSAGING_PORT: 6379
      PREFECT_REDIS_MESSAGING_DB: 0
    command: prefect server start --no-services
    ports:
      - "4200:4200"
Notes - Workers inside the compose network should still use the internal URL, e.g.
PREFECT_API_URL=<http://prefect-server:4200/api>
. - Make sure port mapping
4200:4200
is present and you’re visiting http://localhost:4200 (or the remote host). Helpful references - Self-hosted with Docker Compose (source for the official example): Docs: Docker Compose - UI setting that determines this behavior: prefect.settings.server.ui If this doesn’t fix it, can you share: - Whether you’re running locally or on a remote VM - The
prefect-server
section of your compose file - Any logs from the
prefect-server
container right after startup I’ll help you get it sorted quickly.
v
@Marvin I am running in my local and I am using localhost in url and not 0.0.0.0 . This is the prefect server section in the compose file prefect-server: image: prefecthq/prefect:3-latest depends_on: postgres: condition: service_healthy redis: condition: service_healthy environment: PREFECT_API_DATABASE_CONNECTION_URL: postgresql+asyncpg://prefect:prefect@postgres:5432/prefect PREFECT_SERVER_API_HOST: 0.0.0.0 PREFECT_MESSAGING_BROKER: prefect_redis.messaging PREFECT_MESSAGING_CACHE: prefect_redis.messaging PREFECT_REDIS_MESSAGING_HOST: redis PREFECT_REDIS_MESSAGING_PORT: 6379 PREFECT_REDIS_MESSAGING_DB: 0 command: prefect server start --no-services ports: - "4200:4200" Prefect server logs : View the API reference documentation at http://0.0.0.0:4200/docs prefect-server-1 | prefect-server-1 | Check out the dashboard at http://0.0.0.0:4200
m
thought for 41.4 seconds
Thanks for sharing the compose and logs — that helps. What’s going on - Your browser is opening http://localhost:4200, but the UI still tries to call the API at http://0.0.0.0:4200/api because the UI’s API target is derived from the server’s bind host when
PREFECT_UI_API_URL
is not explicitly set. - The log lines showing 0.0.0.0 are expected (that’s the bind address inside the container), but the UI needs a browser-reachable URL. Fix - Add
PREFECT_UI_API_URL
to the
prefect-server
service so the UI knows to call localhost:
Copy code
prefect-server:
  image: prefecthq/prefect:3-latest
  depends_on:
    postgres:
      condition: service_healthy
    redis:
      condition: service_healthy
  environment:
    PREFECT_API_DATABASE_CONNECTION_URL: <postgresql+asyncpg://prefect:prefect@postgres:5432/prefect>
    PREFECT_SERVER_API_HOST: 0.0.0.0
    PREFECT_UI_API_URL: <http://localhost:4200/api>
    PREFECT_MESSAGING_BROKER: prefect_redis.messaging
    PREFECT_MESSAGING_CACHE: prefect_redis.messaging
    PREFECT_REDIS_MESSAGING_HOST: redis
    PREFECT_REDIS_MESSAGING_PORT: 6379
    PREFECT_REDIS_MESSAGING_DB: 0
  command: prefect server start --no-services
  ports:
    - "4200:4200"
Then recreate the container:
Copy code
docker compose up -d --force-recreate
And hard-refresh the UI (Shift+Reload or Ctrl/Cmd+Shift+R). Quick checks - Open http://localhost:4200/docs — if that loads, the API is up. - In DevTools > Network, the UI calls should now hit http://localhost:4200/api/... (not 0.0.0.0). References - Official Docker Compose guide: Docs: Docker Compose - UI setting used to determine the API URL: prefect.settings.server.ui If you still see the error after this, please share: - A fresh log snippet from the
prefect-server
container after restart - Screenshot or text of the failing UI Network request URL in DevTools - Confirmation that you’re visiting http://localhost:4200 (no proxies in between)