Fix RunPod pod not starting
Quick answer
If your
RunPod pod is not starting, first verify your RUNPOD_API_KEY is correctly set in your environment and that your pod configuration matches the endpoint requirements. Also, ensure your pod's resource limits and image are valid and that you are using the latest runpod Python SDK with proper synchronous or asynchronous invocation patterns.PREREQUISITES
Python 3.8+RunPod API key (set RUNPOD_API_KEY environment variable)pip install runpod
Setup
Install the official runpod Python package and set your API key as an environment variable to authenticate requests.
- Install the SDK:
pip install runpod - Set your API key in your shell environment:
export RUNPOD_API_KEY='your_api_key'(Linux/macOS) orsetx RUNPOD_API_KEY "your_api_key"(Windows)
pip install runpod output
Collecting runpod Downloading runpod-1.0.0-py3-none-any.whl (10 kB) Installing collected packages: runpod Successfully installed runpod-1.0.0
Step by step
Use this minimal example to start a RunPod pod synchronously and check its status. Replace YOUR_ENDPOINT_ID with your actual pod endpoint ID.
import os
import runpod
runpod.api_key = os.environ["RUNPOD_API_KEY"]
endpoint = runpod.Endpoint("YOUR_ENDPOINT_ID")
# Run a synchronous job
result = endpoint.run_sync({"input": {"prompt": "Hello from RunPod!"}})
print("Pod output:", result["output"]) output
Pod output: Hello from RunPod!
Common variations
You can also run pods asynchronously or use a serverless handler for event-driven execution.
- Async example:
import os
import asyncio
import runpod
runpod.api_key = os.environ["RUNPOD_API_KEY"]
async def main():
endpoint = runpod.Endpoint("YOUR_ENDPOINT_ID")
result = await endpoint.run({"input": {"prompt": "Async RunPod call"}})
print("Async pod output:", result["output"])
asyncio.run(main()) output
Async pod output: Async RunPod call
Troubleshooting
If your pod does not start, check the following:
- Ensure
RUNPOD_API_KEYis set and valid. - Verify your pod endpoint ID is correct and active.
- Check pod resource limits and image compatibility in the RunPod dashboard.
- Inspect error messages returned by
run_syncorruncalls for clues. - Confirm your network allows outbound HTTPS requests to RunPod API.
Example error handling:
try:
result = endpoint.run_sync({"input": {"prompt": "Test"}})
print("Pod output:", result["output"])
except Exception as e:
print("Failed to start pod:", e) output
Failed to start pod: Invalid API key or endpoint not found
Key Takeaways
- Always set and verify your RUNPOD_API_KEY environment variable before running pods.
- Use the latest runpod Python SDK and follow synchronous or asynchronous invocation patterns.
- Check pod configuration and resource limits in the RunPod dashboard if pods fail to start.
- Handle exceptions in your code to catch and diagnose pod startup errors quickly.