Building with Axum?

Axum handlers refusing to compile or run? We unstick it.

Axum is pleasant until a route refuses to compile because an extractor sits in the wrong position, a Tower layer silently stops firing, or a State is missing a Clone implementation three traits deep. We read the trait bounds, straighten the request flow, and leave the handler behaving the way the signature promised.

  • Since 2015Fixing technology
  • FreeEstimates
  • US teamReal engineers

cargo-build.log

still broken

What it is

Axum at a glance

Axum is a Rust web framework built on top of Tokio, Hyper and the Tower service stack. It was first released by the Tokio project in 2021 and has become the default pick for new Rust HTTP services, replacing older choices like Rocket and Warp for a lot of teams.

The design relies heavily on Rust's type system: handlers are regular async functions whose parameters are extractors, and middleware is any Tower layer that wraps a Service. That makes the framework thin and composable, at the cost of error messages that can read like a short novel when something upstream goes wrong.

Type
Async web framework for Rust
First released
2021 by the Tokio project
License
MIT, free and open source
Maintained by
The Tokio maintainers and community contributors
Typically used for
JSON APIs, gRPC gateways, real time services, backends for Rust shops

The honest version

Axum pros and cons

No technology is all upside. This is where Axum earns its place and where it tends to cause trouble.

Where Axum is strong

  • Handlers are just async functionsNo macros wrap the request flow, no runtime registration happens, and the compiler proves most routing mistakes before the binary ever runs.
  • Tower compatibility opens a big ecosystemAny Tower service, timeout, retry, trace or auth layer works with Axum directly, so you inherit a mature middleware library rather than reimplementing one.
  • Extractors keep handlers tidyPath, Query, Json, Form, State and Extension all compose through function arguments, which keeps the handler body focused on business logic.
  • First class tracingIntegration with the tracing crate is idiomatic, so request spans, structured logs and OpenTelemetry sinks drop in without wrestling the framework.
  • Fast with low memory overheadHyper plus Tokio gives you a runtime that holds up under heavy load on small nodes, which matters when you are sizing containers.
  • The team ships at a steady cadenceReleases arrive with clear migration notes, so upgrading between minor versions rarely turns into a week long project.

Where Axum bites

  • Trait errors can be brutal to readA forgotten Clone on AppState or an extractor in the wrong position produces an error page of bounds that only an experienced Rust engineer will unpick quickly.
  • Extractor order matters and is not obviousAnything that consumes the body must come last. Putting Request or Body before Json or Form silently breaks handlers in ways the signature does not warn about.
  • Middleware layering is counterintuitiveLayers apply in reverse order of addition, and from_fn_with_state behaves differently from route_layer. Teams often discover this after a timeout layer does not actually time anything out.
  • Compile times grow fastHeavy extractor stacks and generic routers can push incremental builds into the tens of seconds, which hurts the feedback loop on a laptop.
  • Smaller hiring poolFinding engineers who are comfortable with Rust async, Tower, and the Axum idioms at the same time is harder than hiring Node or Go developers.
  • Ecosystem gaps remainMature equivalents of Django admin, Rails generators or NestJS modules simply do not exist, so teams write more scaffolding themselves.

Sound familiar?

Common Axum problems we fix

The Axum problems that bring people to us, and what you have once each one is fixed.

trait bound `Handler<_, _>` is not satisfied

A route refuses to compile

A handler signature the compiler cannot match to a Handler implementation, usually because an extractor is in the wrong position or State is not Clone.

Signatures match, cargo builds

Missing extension of type `State<AppState>`

State is missing at runtime

A router that was built without .with_state, or a nested Router that lost the state type when it was merged in the wrong order.

State threaded all the way through

Body already consumed

The request body disappears before the handler reads it

A middleware that reads the body for logging or signing, then does not put it back, leaving the real handler empty.

Body preserved end to end

tower layer not firing

A middleware layer is not running

A layer added after a .route() call instead of as route_layer or layer on the Router, so requests skip it entirely.

Layers wrapped in the right order

Json rejection: Failed to parse

JSON payloads fail validation at the edge

A content type mismatch, a slightly wrong field name, or a serde default that hides the real cause from the client.

Parsers aligned with the schema

hyper: connection closed before message completed

Long requests get dropped

A reverse proxy idle timeout, a missing keepalive setting, or a handler that streams responses without flushing between chunks.

Streams complete, proxies aligned

overflow evaluating the requirement

Nested routers blow the trait resolver

A merge or nest of generic routers that makes the type checker chase itself. Boxing the inner service or splitting routes resolves it.

Build reaches a fixed point

Missing Clone on AppState

Shared state will not compile into the handler

An AppState struct that holds a non Clone value, or a Mutex that was not wrapped in Arc, breaking every extractor that depends on it.

State is cheap to share

What we do

Axum help, from compile errors to production shape

One handler that will not build, or a whole service you want hardened, either works for us.

Rescue
A build that is red, a handler that returns the wrong shape, or a middleware that no longer runs. We stabilize the service first and explain second.
Extractor and state design
Handler signatures, AppState layout and route grouping worked out so the compiler stops fighting you on every change.
Tower middleware
Tracing, auth, rate limits, timeouts and compression layered in the right order, with tests that prove each one fires.
Performance tuning
Tokio runtime settings, Hyper keepalive, body size limits and response streaming adjusted against real traffic rather than defaults.
Observability
Structured tracing spans, OpenTelemetry export and useful request logs wired into whatever sink you already pay for.
Managed Tech
A Rust team on call for crates upgrades, Tokio bumps and the odd production trace that only a seasoned engineer wants to read.

How it works

From first message to fixed

  1. Look Free estimate

    Tell us what's going wrong. We look at it, then tell you plainly what's wrong and what it will cost.

  2. Fix

    We fix the cause, not the symptom. If something is down, getting it back up comes first.

  3. Harden

    Backups, monitoring, updates and access, so the same problem can't quietly come back.

  4. Hand back or stay on

    You get a plain-language write-up. Or we stay on for hosting, upkeep and new work.

Often found together

Running Axum alongside something else?

We work on the whole stack, so the problem can be wherever it actually is.

Questions

Axum questions

Something else? Call+1 737 727 7327

Why does my Axum handler refuse to compile?

Nine times out of ten the trait bound error is telling you an extractor is in the wrong position, or that AppState is not Clone, or that a type parameter cannot be inferred because you nested routers without specifying the state type. The compiler is strict for a reason, but the message is written for the trait solver rather than the engineer. We read it as a stack, not a block of text.

Why is my Tower middleware not firing on an Axum route?

Layers apply in reverse order of addition, and the method you use decides the scope. .layer on the Router wraps everything; route_layer wraps a single route; from_fn only runs when it is actually included in the service stack. A layer added after .route() may only affect routes added after it, which is a common source of silent misses.

Is Axum faster than Actix Web or Rocket?

In raw benchmarks Axum is within a few percent of Actix Web and comfortably ahead of Rocket. The honest answer is that in production the framework rarely decides your throughput; the database, serialization and network pattern do. Axum wins on compile safety and ecosystem fit with Tokio, not on microbenchmarks.

Can we migrate from Actix or Rocket to Axum?

Yes, and it is a common request. The route surface usually ports in a few days, the state and middleware take longer because the idioms differ, and the test suite is where most of the effort lands. We do it one service at a time rather than a big bang.

How do we handle long running requests in Axum?

Set an explicit TimeoutLayer, cap the request body size, use StreamBody for response streams, and keep the Hyper keepalive aligned with your load balancer. Long requests dropped mid flight are almost always a proxy timeout mismatch rather than an Axum fault.

How much does Axum help cost?

Quotes are free. Send us the failing build output or a short description of the service, and a price lands before any work starts.

Free estimate

Axum fighting you?

Paste the compile error or describe the service, and a Rust engineer replies with a price and a plan.

  • No charge to find out what it will take
  • If it's urgent, say so

Replies come from a person. By sending, you authorize us to email you back. No marketing.