Why do I get the error “there is no reactor running, must be called from the context of Tokio runtime” even though I have #[tokio::main]?

You are using a newer version of Tokio, such as 0.3 or 1.x, and many packages, including mdns 1.1.0, rely on an older version of Tokio, such as 0.2.

% cargo tree -d
tokio v0.2.22
└── mdns v1.1.0
    └── example_project v0.1.0

tokio v0.3.3
└── example_project v0.1.0

For now, you will need to match versions of the Tokio runtime. The easiest way is to use Tokio 0.2 yourself. The tokio-compat-02 crate may also be useful in some cases.

See also:

  • Why is a trait not implemented for a type that clearly has it implemented?

Various error messages with the same root cause:

there is no reactor running, must be called from the context of a Tokio 1.x runtime

there is no reactor running, must be called from the context of Tokio runtime

not currently running on the Tokio runtime

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)