Peter Žáčik
11/06/2025, 2:04 PMCan't connect to server API at <http://0.0.0.0:4200/api> when connecting via the network (edited)Marvin
11/06/2025, 2:04 PMMarvin
11/06/2025, 2:09 PM0.0.0.0 is correct, but the UI cannot call <http://0.0.0.0:4200/api> from your laptop. You must tell the UI the externally reachable address.
In Prefect 3.x, set:
- PREFECT_SERVER_API_HOST to 0.0.0.0 (bind to all interfaces)
- PREFECT_SERVER_API_PORT to your port (4200 by default)
- PREFECT_SERVER_UI_API_URL to the externally reachable URL of your API, e.g. http://<vm-ip-or-dns>:4200/api
- Optionally, set PREFECT_API_URL to the same value for CLI/workers
On Windows PowerShell:
$env:PREFECT_SERVER_API_HOST = '0.0.0.0'
$env:PREFECT_SERVER_API_PORT = '4200'
$env:PREFECT_SERVER_UI_API_URL = 'http://<vm-ip-or-dns>:4200/api'
$env:PREFECT_API_URL = 'http://<vm-ip-or-dns>:4200/api' # optional but recommended
prefect server start --host 0.0.0.0 --port 4200
On cmd.exe:
set PREFECT_SERVER_API_HOST=0.0.0.0
set PREFECT_SERVER_API_PORT=4200
set PREFECT_SERVER_UI_API_URL=http://<vm-ip-or-dns>:4200/api
set PREFECT_API_URL=http://<vm-ip-or-dns>:4200/api
prefect server start --host 0.0.0.0 --port 4200
Quick checks:
- From your laptop, open http//<vm ip or dns>4200
- Test the API directly: http//<vm ip or dns>4200/api/hello
- Ensure the Windows Firewall (and any network security group) allows inbound TCP 4200
Notes:
- If you’re fronting the server with HTTPS or a reverse proxy, set PREFECT_SERVER_UI_API_URL to that external HTTPS URL, e.g. <https://prefect.yourdomain.com/api>.
- Set these env vars before starting the server; the UI reads them at startup.
Docs for reference:
- Self-hosting Prefect Server
- Server CLI options
- Windows notes
- Settings reference
If you share the VM’s IP/DNS and whether you’re using a reverse proxy, I can suggest the exact values to use.Peter Žáčik
11/06/2025, 2:11 PMMarvin
11/06/2025, 2:11 PMMarvin
11/06/2025, 2:12 PMPREFECT_SERVER_UI_API_URL is reachable from both places.
Details:
- Set the server to bind on all interfaces: --host 0.0.0.0 (and open port 4200 in Windows Firewall).
- Set PREFECT_SERVER_UI_API_URL to a single, consistent URL that both your VM and external clients can reach, e.g. <http://prefect.yourdomain.com/api> (or https://... behind a reverse proxy).
- Then access the UI at the same host/port (e.g., http://prefect.yourdomain.com).
If you point PREFECT_SERVER_UI_API_URL to a public IP/DNS:
- It will work externally.
- It will also work from inside the VM if the VM can resolve/reach that public address (hairpin NAT). If not, add a hosts entry or use a DNS name that resolves to the VM’s internal IP on your LAN (split-horizon DNS).
If you point it to a private IP:
- It will work from inside the network.
- It will not work externally.
Best practice: use a DNS name (e.g., <http://prefect.example.com|prefect.example.com>) and ensure both internal and external clients (and the VM itself) can resolve it appropriately.
Refs:
- Server CLI options
- Self-hosting Prefect Server