1 unstable release

0.9.0 Mar 2, 2024

#1062 in Network programming

Download history 566/week @ 2024-02-27 4123/week @ 2024-03-05 4544/week @ 2024-03-12 8501/week @ 2024-03-19 8235/week @ 2024-03-26 12975/week @ 2024-04-02 12315/week @ 2024-04-09 11831/week @ 2024-04-16 14851/week @ 2024-04-23 15989/week @ 2024-04-30 17778/week @ 2024-05-07 20014/week @ 2024-05-14 22704/week @ 2024-05-21 24128/week @ 2024-05-28 24409/week @ 2024-06-04 21638/week @ 2024-06-11

95,941 downloads per month
Used in 62 crates (2 directly)

MIT license

182 lines

🔌 ✨


Hyper client and server bindings for Unix domain sockets

Hyper is a rock solid Rust HTTP client and server toolkit. Unix domain sockets provide a mechanism for host-local interprocess communication. hyperlocal builds on and complements Hyper's interfaces for building Unix domain socket HTTP clients and servers.

This is useful for exposing simple HTTP interfaces for your Unix daemons in cases where you want to limit access to the current host, in which case, opening and exposing tcp ports is not needed. Examples of Unix daemons that provide this kind of host local interface include Docker, a process container manager.


Add the following to your Cargo.toml file

hyperlocal = "0.9"



A typical server can be built by creating a tokio::net::UnixListener and accepting connections in a loop using hyper::service::service_fn to create a request/response processing function, and connecting the UnixStream to it using hyper::server::conn::http1::Builder::new().serve_connection().

An example is at examples/server.rs.

To test that your server is working you can use an out-of-the-box tool like curl

$ curl --unix-socket /tmp/hyperlocal.sock localhost

It's a Unix system. I know this.


hyperlocal also provides bindings for writing unix domain socket based HTTP clients the Client interface from the hyper-utils crate.

An example is at examples/client.rs.

Hyper's client interface makes it easy to send typical HTTP methods like GET, POST, DELETE with factory methods, get, post, delete, etc. These require an argument that can be tranformed into a hyper::Uri.

Since Unix domain sockets aren't represented with hostnames that resolve to ip addresses coupled with network ports, your standard over the counter URL string won't do. Instead, use a hyperlocal::Uri, which represents both file path to the domain socket and the resource URI path and query string.

Doug Tangren (softprops) 2015-2020


~124K SLoC