---
name: "pkg-serve"
section: "8"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/pkg-serve"
---

# pkg-serve(8)

serve pkg repositories over TCP via inetd

## NAME

**pkg-serve** – serve pkg repositories over TCP via inetd

## SYNOPSIS

**pkg-serve** *basedir*

## DESCRIPTION

The **pkg-serve** utility serves pkg(8) repositories using the pkg TCP protocol. It is designed to be invoked by [inetd(8)](/inetd/8.md) and communicates via standard input and output.

The *basedir* argument specifies the root directory containing the package repositories. All file requests are resolved relative to this directory.

On startup, **pkg-serve** enters a Capsicum sandbox, restricting filesystem access to *basedir*.

## PROTOCOL

The protocol is line-oriented. Upon connection, the server sends a greeting:

```
ok: pkg-serve <version>
```

The client may then issue commands:

- **get** *file* *age*

  Request a file. If the file's modification time is newer than *age* (a Unix timestamp), the server responds with:

  ```
  ok: <size>
  ```

  followed by *size* bytes of file data. If the file has not been modified, the server responds with:

  ```
  ok: 0
  ```

  On error, the server responds with:

  ```
  ko: <error message>
  ```

- **quit**

  Close the connection.

## INETD CONFIGURATION

Add the following line to [inetd.conf(5)](/inetd.conf/5.md):

```
pkg  stream  tcp  nowait  nobody  /usr/libexec/pkg-serve  pkg-serve /usr/local/poudriere/data/packages
```

And define the service in [services(5)](/services/5.md):

```
pkg     62000/tcp
```

## REPOSITORY CONFIGURATION

On the client side, configure a repository in */usr/local/etc/pkg/repos/myrepo.conf* to use the **tcp://** scheme:

```
myrepo: {
    url: "tcp://pkgserver.example.com:62000/myrepo",
}
```

The path component of the URL is resolved relative to the *basedir* given to **pkg-serve**. For example, if **pkg-serve** is started with */usr/local/poudriere/data/packages* as *basedir*, the above configuration will serve files from */usr/local/poudriere/data/packages/myrepo/*.

## SEE ALSO

[inetd.conf(5)](/inetd.conf/5.md), [inetd(8)](/inetd/8.md), pkg(8)

## AUTHORS

Baptiste Daroussin ⟨*bapt@FreeBSD.org*⟩
