<@ULVA73B9P> when doing local prefect 3 runs, it s...
# marvin-ai
m
@Marvin when doing local prefect 3 runs, it spawns multiple temporary server. Is the behaviour expected?
m
thought for 367.0 seconds
Short answer: yes — that can be expected. What you’re seeing are “ephemeral” (temporary) Prefect servers that start automatically when you run flows locally without pointing at an existing API. If you kick off multiple runs from separate processes/terminals, each process can start its own ephemeral server. How to avoid multiple ephemeral servers - Use a single persistent local server and point your profile at it:
Copy code
prefect server start
  # then set your profile to use that API URL so future runs reuse it
  prefect config set PREFECT_API_URL=http://<host>:<port>
Docs: Server CLI - Or disable ephemeral servers entirely (flows will run “offline” and won’t record to a server/UI):
Copy code
# one-time in your current profile
  prefect config set PREFECT_SERVER__EPHEMERAL__ENABLED=false
  # or via env var
  export PREFECT_SERVER__EPHEMERAL__ENABLED=false
Settings reference: ServerEphemeralSettings Notes - If you’re connected to Prefect Cloud or a self-hosted server (i.e.,
PREFECT_API_URL
is set), Prefect won’t start an ephemeral server. - Ephemeral servers are per-process and shut down when the process exits. If you can share how you’re running flows (e.g.,
python flow.py
,
prefect run
, multiple terminals, etc.), I can suggest the cleanest setup for your case.
m
@Marvin but when disabling ephemeral servers entirely (flows will run “offline” and won’t record to a server/UI):
m
thought for 182.3 seconds
Got it — can you share what happens when you disable ephemeral servers? Do you see errors, or are you expecting certain UI/logging features to still work? Here’s what to expect when you truly run “offline” (no server, no ephemeral): - Your flow still runs locally and returns results in-process. - Nothing is recorded to a server/UI: no flow/task states, no logs in the UI, no artifacts, no variables/blocks fetched from API, no automations/concurrency. - Anything that requires the API (e.g., deployments, variables, block documents, artifacts, pause/resume) will fail or be skipped. How to ensure you’re offline (and avoid ephemeral servers) - Disable ephemeral server:
Copy code
prefect config set PREFECT_SERVER__EPHEMERAL__ENABLED=false
- Make sure you are not pointing at any API:
Copy code
prefect config unset PREFECT_API_URL
or verify:
Copy code
prefect config view --show-defaults
You should NOT see
PREFECT_API_URL=http://...
and should NOT see
PREFECT_API_URL=ephemeral
. Optional: silence API logging attempts when offline - Prefect can try to send logs to the API if that feature is on. Turn it off to avoid noise:
Copy code
prefect config set PREFECT_LOGGING__TO_API__ENABLED=false
Settings ref: Settings reference If you want a single server instead of many ephemeral ones - Start a persistent local server and reuse it:
Copy code
prefect server start
  prefect config set PREFECT_API_URL=<http://localhost:4200>  # adjust if needed
Docs: Server CLI If you’re seeing different behavior after disabling ephemeral servers, please paste the exact command you’re running and any log output — I’ll help pinpoint what’s still triggering server usage.
m
@Marvin we set profile as below:
Copy code
PREFECT_SERVER_ALLOW_EPHEMERAL_MODE='false' (from profile)
PREFECT_SERVER_EPHEMERAL_ENABLED='false' (from profile)
But when running the flow we are seeing below error
ValueError: No Prefect API URL provided. Please set PREFECT_API_URL to the address of a running Prefect server.
m
thought for 171.2 seconds
Thanks for sharing the settings. That error is expected if your flow (or anything it calls) needs the Prefect API, because you’ve disabled ephemeral servers and haven’t set a persistent
PREFECT_API_URL
. Two important points: - The correct setting to disable ephemeral servers in Prefect 3 is
PREFECT_SERVER__EPHEMERAL__ENABLED=false
(note the double underscores). You can confirm your active values with:
Copy code
prefect config view --show-defaults
Docs: ServerEphemeralSettings -
PREFECT_SERVER_ALLOW_EPHEMERAL_MODE
is not a Prefect 3 setting; you can remove it. Why you’re seeing the error - With ephemeral disabled, Prefect will not auto-start a server. If your code uses any API-dependent features, you’ll get:
Copy code
ValueError: No Prefect API URL provided. Please set PREFECT_API_URL ...
- Common API-dependent features: - Deployments (
flow.from_source(...).deploy(...)
,
prefect.deploy
,
prefect.serve
) - Variables or blocks (
Variable.get
,
Block.load
, filesystem blocks) - Artifacts (
create_markdown_artifact
,
create_table_artifact
, etc.) - Client usage (
get_client
,
PrefectClient
) - Pause/resume, automations, concurrency limits, events - Running a deployment by name (
run_deployment
) How to proceed (pick one) 1) Keep running offline (no server) - Remove or guard calls that require the API. - Optionally turn off logging-to-API to avoid noise:
Copy code
prefect config set PREFECT_LOGGING__TO_API__ENABLED=false
- Then run your flow by calling the function directly (e.g.,
python your_flow.py
). This will work without
PREFECT_API_URL
. 2) Use a persistent local server instead of ephemeral - Start one server and point your profile to it so all runs reuse it:
Copy code
prefect server start
  prefect config set PREFECT_API_URL=<http://localhost:4200>   # adjust to your host/port
Docs: Server CLI Quick checklist - Verify ephemeral is really off:
Copy code
prefect config view --show-defaults
Ensure you see
PREFECT_SERVER__EPHEMERAL__ENABLED=false
. - If you want offline: ensure there’s no
PREFECT_API_URL
set and no API-dependent feature is used. - If you want server-backed features: set
PREFECT_API_URL
to a running server. If you paste the stack trace or share which Prefect features your flow uses (e.g., artifacts, variables, deployments), I can point out exactly which call is triggering the API requirement and suggest a workaround.