Skip to main content
Testing your handler locally before deploying saves time and helps you catch issues early. The Runpod SDK provides multiple ways to test your handler function without consuming cloud resources. See the Serverless development overview for the complete development lifecycle.

Basic testing

The simplest way to test your handler is by running it directly with test input.

Inline JSON

Pass test input directly via the command line:
This runs your handler with the specified input and displays the output in your terminal.

Test file

For more complex or reusable test inputs, create a test_input.json file in the same directory as your handler:
test_input.json
Run your handler without any arguments:
The SDK automatically detects and uses the test_input.json file.
If you provide both a test_input.json file and the --test_input flag, the command-line input takes precedence.

Local API server

For more comprehensive testing, start a local API server that simulates your Serverless endpoint. This lets you send HTTP requests to test your handler as if it were deployed. Start the local server:
This starts a FastAPI server on http://localhost:8000.

Send requests to the server

Once your local server is running, send HTTP POST requests from another terminal to test your function:
The /run endpoint only returns a fake request ID without executing your code, since async mode requires communication with Runpod’s system. For local testing, use /runsync to execute your handler and get results immediately.

Testing concurrency

The local API server runs as a single process and handles every request on one event loop. To test how your handler behaves when several requests arrive at once, write it as an async function and send overlapping requests to the server. An async handler that awaits I/O works on overlapping requests at the same time, while a synchronous handler processes them one after another. The --rp_api_concurrency flag doesn’t start more server processes. If you set it above 1, the server logs a warning and starts a single worker process.

Testing concurrent requests

Send multiple requests simultaneously to test concurrency:

Handling concurrency in your code

If your handler uses shared state (like global variables), use proper synchronization to avoid race conditions:

Debugging

Log levels

Control the verbosity of console output with the --rp_log_level flag:
Available log levels:
  • ERROR: Only show error messages.
  • WARN: Show warnings and errors.
  • INFO: Show general information, warnings, and errors.
  • DEBUG: Show all messages, including detailed debug information.

Enable the debugger

Use the --rp_debugger flag for detailed troubleshooting:
This enables the Runpod debugger, which provides additional diagnostic information to help you troubleshoot issues.

Server configuration

Customize the local API server with these flags:

Port

Set a custom port (default is 8000):

Host

Set the hostname (default is “localhost”):
Setting --rp_api_host to 0.0.0.0 allows connections from other devices on the network. This can be useful for testing but may have security implications.

Flag reference

Here’s a complete reference of all available flags for local testing:

Combined example

You can combine multiple flags to create a customized local testing environment:
This command:
  • Starts the local API server on port 8080.
  • Sets the log level to DEBUG for maximum information.
  • Enables the debugger for troubleshooting.
Last modified on December 3, 2026