Cannot start a runtime from within a runtime (Tokio) Rust Origin: Application & API OSI layer 7 · Application Last updated 5 Nov 2026

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

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

Exact message you may see Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.Cannot drop a runtime in a context where blocking is not allowedCannot start a runtime from within a runtimethread 'main' panicked: Cannot start a runtime from within a runtime
Seen on: Rust

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?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

Blocking waiting for file lock on package cache / build directory — Cargo: Blocking waiting for file lock on package cache / on build directory (Rust)Blocking waiting for …cargo: failed to get from registry (spurious network error) — Cargo: warning: spurious network error (2 tries remaining): [35] SSL connect error / error: failed to download from `https://index.crates.io/...` (Rust)cargo: failed to get …cargo: failed to select a version for the requirement — Cargo: error: failed to select a version for the requirement `serde = "^2.0"` — candidate versions found which didn't match: 1.0.197 (Rust)cargo: failed to sele…E0521: borrowed data escapes outside of function — Rust: error[E0521]: borrowed data escapes outside of function — `data` escapes the function body here (tokio::spawn requires 'static) (Rust)E0521: borrowed data …E0728: await is only allowed inside async functions and blocks — Rust: error[E0728]: `await` is only allowed inside `async` functions and blocks (Rust)E0728: await is only …E0752: main function is not allowed to be async — Rust: error[E0752]: `main` function is not allowed to be `async` (Rust)E0752: main function …there is no reactor running, must be called from the context of a Tokio 1.x runtime — Rust: thread 'main' panicked: there is no reactor running, must be called from the context of a Tokio 1.x runtime (Rust)there is no reactor r…Cannot st…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.