<@ULVA73B9P> I am seeing a error when attempting t...
# ask-marvin
e
@Marvin I am seeing a error when attempting to connect to my prefect server fro my UI: Can't connect to Server API at http://0.0.0.0:4200/api. Check that it's accessible from your machine. This is the output of prefect config view: prefect config view --show-secrets 132936.280 | DEBUG | prefect.profiles - Using profile 'dev' 🚀 you are connected to: http://127.0.0.1:4200 PREFECT_PROFILE='dev' PREFECT_API_URL='http://127.0.0.1:4200/api' (from profile) PREFECT_LOGGING_LEVEL='DEBUG' (from profile) Any ideas?
m
âś… thought for 258.4 seconds
Thanks for the details — this is a common gotcha. What’s happening - Your browser-based UI is trying to reach the API at http://0.0.0.0:4200/api. The address 0.0.0.0 is a bind address (listen on all interfaces), not something a browser can actually connect to. - Your CLI config shows PREFECT_API_URL=http://127.0.0.1:4200/api, which is correct for local access — but that’s your client config. The server/UI is still “advertising” 0.0.0.0 because of how it was started. Fixes For local development, explicitly bind the server to 127.0.0.1 (or your machine’s LAN IP if you’re accessing from another device): - Simple local fix (recommended):
Copy code
prefect server start --host 127.0.0.1 --port 4200
Then open http://127.0.0.1:4200 and the UI should connect to http://127.0.0.1:4200/api. - If you need remote access from another machine on your network: 1) Find your machine’s IP (e.g., 192.168.x.y) 2)
Copy code
prefect server start --host 192.168.x.y --port 4200
3) Access the UI at http://192.168.x.y:4200 from the other machine Sanity checks - Health endpoint from the same machine:
Copy code
curl <http://127.0.0.1:4200/api/health>
You should see a healthy response. - Make sure you’re actually visiting the UI at http://127.0.0.1:4200 (or your chosen host), not http://0.0.0.0:4200. A couple of clarifying questions (to ensure we land the right config) - How are you starting the server? e.g., just
prefect server start
, or with custom flags, or via Docker? - Are you accessing the UI from the same machine running the server, or from another device? References - Self-hosted server docs: Prefect 3.x: Self-hosted - Managing settings: Prefect 3.x: Manage settings If you share the exact command you used to start the server (and whether you’re local vs remote), I can tailor the exact flags/env vars.
e
@Marvin I am starting the server from a local docker container. I am accessing the UI from the same machine running the server
m
âś… thought for 107.6 seconds
Got it — thanks for clarifying. Since you’re running Prefect Server in a Docker container and accessing the UI from the same machine, the issue is that the UI inside the container is trying to call the API at 0.0.0.0:4200/api. 0.0.0.0 is a bind address; your browser can’t reach it. What to do - Keep the API listening on 0.0.0.0 inside the container (so Docker can expose it) - Tell the UI to call the API via a browser-reachable URL. The simplest is to use a same-origin relative path: /api Run examples - docker run
Copy code
docker run --rm -p 4200:4200 \
  -e PREFECT_UI_API_URL=/api \
  prefecthq/prefect:3-latest \
  prefect server start --host 0.0.0.0 --port 4200
- docker-compose
Copy code
services:
  prefect:
    image: prefecthq/prefect:3-latest
    command: prefect server start --host 0.0.0.0 --port 4200
    environment:
      - PREFECT_UI_API_URL=/api
    ports:
      - "4200:4200"
Then open http://localhost:4200 and the UI should connect to /api (same origin), which maps to the API inside the container. Notes - Your local PREFECT_API_URL= http://127.0.0.1:4200/api is for CLI/clients on your host. It doesn’t control what the UI uses inside the container. The UI uses PREFECT_UI_API_URL. - If you prefer an absolute URL instead of same-origin, set
PREFECT_UI_API_URL=<http://localhost:4200/api>
. - After changing the container env, hard refresh the browser in case anything was cached. Quick health check
Copy code
curl <http://localhost:4200/api/health>
You should get a healthy response. Docs - Self-hosted server: Prefect 3.x: Self-hosted - Manage settings: Prefect 3.x: Manage settings If you can share your current docker run or compose snippet, I’ll sanity-check it for you.