# fetch with unix domain sockets in Bun (/docs/guides/http/fetch-unix)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 249 · updated: 2026-07-28 -->
Related: [Common HTTP server usage](/docs/guides/http/server.md), [Write a simple HTTP server](/docs/guides/http/simple.md), [Send an HTTP request using fetch](/docs/guides/http/fetch.md), [Hot reload an HTTP server](/docs/guides/http/hot.md), [Start a cluster of HTTP servers](/docs/guides/http/cluster.md), [Configure TLS on an HTTP server](/docs/guides/http/tls.md)

In Bun, `fetch()` can send HTTP requests over a [unix domain socket](https://en.wikipedia.org/wiki/Unix_domain_socket) with the `unix` option.

```ts fetch-unix.ts icon="/icons/typescript.svg"
const unix = "/var/run/docker.sock";

const response = await fetch("http://localhost/info", { unix });

const body = await response.json();
console.log(body); // { ... }
```

***

The `unix` option is the local file path to a unix domain socket. `fetch()` sends the request over that socket instead of a TCP connection. HTTPS is also supported: use the `https://` protocol in the URL instead of `http://`.

To send a `POST` request to an API endpoint over a unix domain socket:

```ts fetch-unix.ts icon="/icons/typescript.svg"
const response = await fetch("https://hostname/a/path", {
  unix: "/var/run/path/to/unix.sock",
  method: "POST",
  body: JSON.stringify({ message: "Hello from Bun!" }),
  headers: {
    "Content-Type": "application/json",
  },
});

const body = await response.json();
```
