# Rust: thread 'main' panicked: Cannot start a runtime from within a runtime — a function like `block_on` tried to block a thread that drives async tasks

**Code:** `Cannot start a runtime from within a runtime (Tokio)` · **Category:** Rust · **Seen on:** Rust

Blocking code (`block_on`, `reqwest::blocking`) was called inside an async context.

## Meaning

Don't call `block_on` within async code. Make the caller `async` and `.await`, or use `tokio::task::spawn_blocking` for blocking work, or `tokio::task::block_in_place` (multi-thread runtime). `reqwest::blocking` inside `#[tokio::main]` triggers this: use the async client.

## Common causes

- `Runtime::block_on` inside `async fn`
- `reqwest::blocking::get` in async code
- Mixing sync libraries' blocking calls in tasks
- Tests using `#[tokio::test]` with blocking clients
- Nested runtimes

## Quick fix

1. Use async APIs and `.await`
2. `tokio::task::spawn_blocking(|| blocking_work()).await`
3. Replace `reqwest::blocking` with the async client

## Detailed fix by platform

### Rust

1. `let r = tokio::task::spawn_blocking(move
2. heavy()).await?;`

## How to diagnose

1. **Call** — block_on in async?
2. **Client** — blocking?
3. **Fix** — spawn_blocking?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/rust/panic-cannot-start-a-runtime-from-within-a-runtime)
