tokio full feature
Learn what the full feature flag for the tokio crate enables, why it is recommended for Axum beginners, and how to add it to your project.
When you add the tokio crate to an Axum project, you are bringing in the asynchronous runtime that Axum is built on. But tokio is not a single, monolithic piece of code. It is organized into a collection of smaller building blocks that you can turn on or off as needed. The full feature flag turns on all of those building blocks at once. This page explains what that means, why it matters for an Axum project, and how to enable it in your own Cargo.toml file.
Cargo feature flags in plain language
Rust crates can expose optional pieces of functionality through feature flags. A feature flag is a label you put in your Cargo.toml that tells Cargo, "please include this particular part of the crate when you build my project." If you do not turn on a feature, that part of the crate is not compiled into your final binary, which keeps your project smaller and faster to build.
Think of a feature flag like a switch on a power strip. The tokio crate has many switches, each controlling a different tool. Some switches control networking, some control time and delays, some control file access, and so on. There is also one master switch labeled full that flips nearly every switch at the same time - every public feature except test-util and unstable ones.
What the full feature includes
The tokio crate is split into many smaller modules, each with its own feature name. When you write features = ["full"] in your Cargo.toml, you turn on all of these modules. The most important ones for an Axum beginner are:
macros- gives you the#[tokio::main]attribute macro, which sets up the runtime for yourt-multi-thread- the multi-threaded runtime that can run many asynchronous tasks in parallelnet- networking types likeTcpListener, which Axum uses to accept incoming connectionstime- tools for sleeping, timeouts, and intervalsio-util- asynchronous reading and writing helperssync- concurrency primitives like mutexes, channels, and watch channelssignal- support for listening to operating system signals like Ctrl-C
What full really means:
The full feature does not add any new functionality that the individual features do not already provide. It simply enables every feature at once - every public feature, except test-util and unstable features. This is convenient because you do not have to remember which features you need and which you can leave out. For a beginner learning Axum, full removes an entire class of configuration mistakes.
Why an Axum project needs the full feature
Axum itself is built on top of tokio. When you write an Axum application, you will almost always do three things:
- Use the
#[tokio::main]macro to start the async runtime. - Create a
tokio::net::TcpListenerto listen for HTTP requests. - Call
axum::serveand.awaitit.
All three of those things require specific tokio features to be enabled. The macro comes from macros. The multi-threaded runtime that the macro sets up by default comes from rt-multi-thread. The TcpListener type comes from net.
If you only enable a couple of those features and miss one, your code will fail to compile. The full feature guarantees you have everything you need. Axum's own documentation even notes that using #[tokio::main] requires you to enable tokio's macros and rt-multi-thread features or just full.
Adding the full feature to your Cargo.toml
There are two common ways to enable the full feature. Both produce the same result in your Cargo.toml, so pick the one that feels most natural to you.
Open the Cargo.toml file in your project root. It currently has a [dependencies] section with axum and tokio listed. You need to change the tokio line so it includes the feature list.
[package]
name = "my-axum-app"
version = "0.1.0"
edition = "2024"
[dependencies]
axum = "0.8"
tokio = { version = "1", features = ["full"] }
The line tokio = { version = "1", features = ["full"] } tells Cargo to use tokio version 1 and enable the full feature, which turns on every public feature tokio provides (except test-util and unstable ones).
After either approach, your Cargo.toml will have the same tokio entry with features = ["full"]. The exact placement inside the file does not matter as long as it is inside the [dependencies] section.
Everything is set up correctly:
If you run cargo check now and see output that ends with something like Finished dev [unoptimized + debuginfo] target(s), that means Cargo successfully resolved the tokio dependency with the full feature enabled. Your project is ready to use the async runtime without any additional configuration.
Verifying that the feature is active
The best way to confirm that full is enabled is to compile a small Axum program that uses the tokio runtime. The code below is the minimal Axum hello world. If it compiles and runs, the full feature is doing its job.
use axum::{routing::get, Router};
#[tokio::main]
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, World!" }));
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
.await
.unwrap();
axum::serve(listener, app).await.unwrap();
}
When you run cargo run and then visit http://127.0.0.1:3000 in a browser, you should see the text Hello, World!. That simple test proves that the macro, the runtime, and the networking all came from the tokio crate with the full feature turned on.
What happens if you do not enable full
To understand the value of the full feature, it helps to see what happens when it is missing. Suppose your Cargo.toml has only tokio = "1" with no feature list at all. That does not leave tokio with no features: axum already switches on tokio's macros, net, rt, and time features for you, so #[tokio::main] exists and TcpListener is available. What is missing is the multi-threaded runtime itself, so the build fails with:
error: The default runtime flavor is `multi_thread`, but the `rt-multi-thread` feature is disabled.
The #[tokio::main] macro sets up a multi-threaded runtime by default, and that runtime lives behind the rt-multi-thread feature. Without it, the macro has no runtime to start. The full feature avoids this whole family of errors by enabling everything at once.
The errors look different in a project without axum. There, nothing switches on the macros feature for you, so #[tokio::main] does not exist at all and the compiler reports error[E0433]: cannot find 'main' in 'tokio' and error[E0752]: 'main' function is not allowed to be 'async'. And if you enable only macros with no runtime feature at all, the build fails with error: The #[tokio::main] macro requires rt or rt-multi-thread. Those are the errors you will see quoted in tokio-only examples. In an Axum project, the missing piece is almost always rt-multi-thread, and the flavor error above is the one to recognize.
Missing runtime features break compilation:
If you write tokio = { version = "1", features = ["macros"] } and then use #[tokio::main] without also enabling rt-multi-thread, the build fails with this error: The default runtime flavor is multi_thread, but the rt-multi-thread feature is disabled. The full feature avoids this whole family of errors by enabling everything at once.
Common mistakes when enabling tokio features
Beginners often run into three specific problems when configuring tokio for an Axum project. Each one is easy to fix once you know what to look for.
Forgetting the feature list entirely
The most common mistake is writing tokio = "1" and then trying to use #[tokio::main]. The compiler error is about the missing runtime, but the real cause is in Cargo.toml. Always include either features = ["full"] or at least rt-multi-thread - axum already switches on macros for you, so that part is covered.
Misspelling the feature name
Feature names are case-sensitive. Full or FULL are not recognized. It must be exactly full. Also make sure it is inside square brackets in the features array.
Enabling full but forgetting to save Cargo.toml
This sounds trivial, but it happens often. After editing the file, save it, then run cargo check again. Cargo only reads the file from disk, so an unsaved editor buffer does not help.
Check your dependency line carefully:
A line like tokio = { version = "1", features = ["full"] } has three parts: the version, the features key, and the feature array. If any of those is missing or misspelled, Cargo may not enable the feature, and the compiler error will not clearly say "check your Cargo.toml".
When you might not need the full feature
The full feature is ideal for learning and for small projects where build size and compile time are not a concern. In a large production application, you may eventually want to enable only the specific features you actually use. That reduces the final binary size and can slightly speed up compilation. That optimization can wait until the server works. For this page, and for getting your first Axum server running, full is the right choice.
Summary
The tokio full feature is a convenience that enables every optional part of the tokio crate at once. It includes the async runtime, the #[tokio::main] macro, networking types like TcpListener, and many other utilities. Axum depends on several of those parts, so enabling full ensures your Axum project compiles and runs without feature-related errors. You add it by editing the tokio entry in Cargo.toml to include features = ["full"], or by running cargo add tokio --features full. Once that is done, you can run a minimal Axum server and see it respond with "Hello, World!" at 127.0.0.1:3000.
The decision is simple: while you are learning, use full; only trim the list once you know exactly which features your code calls. With full enabled, the runtime side of the project is complete. The remaining work is writing the server code that builds the router and starts listening for requests.