Riya Sinha
09/05/2025, 9:11 PMFlow run infrastructure exited with non-zero status code:
Essential container in task exited (Error Code: 1)
Marvin
09/05/2025, 9:11 PMMarvin
09/05/2025, 9:14 PMprefect flow-run logs <RUN_ID> --tail -n 500
- Inspect the run details (exit code, crash reason):
prefect flow-run inspect <RUN_ID>
3) Turn up verbosity and capture prints
- Set PREFECT_LOGGING_LEVEL=DEBUG
on the deployment (environment variables) or as work pool job variables to get more detailed Prefect logs.
- Capture print()
output in your logs by enabling log_prints
on your flow:
from prefect import flow, get_run_logger
@flow(log_prints=True)
def my_flow():
logger = get_run_logger()
<http://logger.info|logger.info>("Starting flow...")
print("This will appear in Prefect logs too")
- More logging tips: Prefect 3 logging customization
4) Watch for common root causes in hosted runs
- Missing deps or import errors: You’ll typically see pip/install output or a Python ImportError in infrastructure logs. Ensure your project dependencies are declared (and pinned) so the hosted runner installs them.
- Python version mismatch: If your code requires a specific Python version, declare it in your project so hosted infra uses the right interpreter.
- OOM/CPU starvation: If you see exit code 137 or messages about being killed, it’s an out-of-memory kill. Increase memory/CPU on your Prefect-hosted work pool (in the work pool’s settings) or via job variables for that run.
If you share a specific flow run ID (and whether you’re on Prefect 3), I can point you directly to where the infra logs should appear and help interpret the exit code you’re seeing.