<@ULVA73B9P> I have a Prefect Server running on a ...
# marvin-ai
p
@Marvin I have a Prefect Server running on a Windows VM. How to correctly set the API_URL and server host, so the dashboard is accessible from the outside? • If I set the server host and api url to 127.0.0.1, it's not accessible via network • If I set the server host and api url to 0.0.0.0, the dashboard starts to load, but I see error
Can't connect to server API at <http://0.0.0.0:4200/api>
when connecting via the network (edited)
1
m
thought for 286.9 seconds
You’re very close — the key is that there are two different “URLs” involved: - What the server binds to (host/port) - What the browser-based UI uses to reach the API Binding the server to
0.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:
Copy code
$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:
Copy code
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//&lt;vm ip or dns&gt;4200 - Test the API directly: http//&lt;vm ip or dns&gt;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.
p
@Marvin In this case, will the dashboard work from both the inside and the outside of the VM?
m
thought for 40.4 seconds
Short answer: yes — as long as the URL you put in
PREFECT_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