Rust: thread 'main' panicked: there is no reactor running, must be called from the context of a Tokio 1.x runtime
A Tokio API (timer, TCP, tokio::spawn) was used outside a running Tokio runtime.
there is no reactor running, must be called from the context of a Tokio 1.x runtimethere is no reactor running, must be called from the context of a Tokio 0.2.x runtimethread 'main' panicked: there is no reactor runningthere is no reactor running Meaning
Run inside a runtime: #[tokio::main], Runtime::new()?.block_on(...), or #[tokio::test]. When mixing libraries, ensure they use the same Tokio major version (Tokio 0.2 vs 1.x mismatch shows this message). Don't call async code from plain threads without entering the runtime (Handle::enter()).
Common causes
async fn mainwithout the Tokio macro- Calling
tokio::spawn/timers from a non-runtime thread - Tokio 0.2/0.3 dependency mixed with 1.x
- Tests without
#[tokio::test] - Libraries using their own runtime
⚡ Quick fix
#[tokio::main]/#[tokio::test]- Use
Handle::current()andhandle.spawnfrom other threads cargo tree -d | grep tokioto find version mixes
Detailed fix by platform
Rust
cargo tree -i tokioto see which tokio versions are in the graph
How to diagnose
- Runtime — Active?
- Versions — One tokio?
- Thread — Entered handle?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Blocking waiting for file lock on package cache / build directory Cargo: Blocking waiting for file lock on package cache / on build directory
- Cannot start a runtime from within a runtime (Tokio) 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
- 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/...`
Most viewed in Rust
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 5 Nov 2026