Lazy Connections

NetBird now includes an experimental lazy connection feature designed to improve performance and reduce resource usage by connecting to peers only when needed. Instead of maintaining always-on connections, NetBird activates them on-demand based on activity or signaling.

This guide walks you through enabling and configuring this feature in your NetBird client.

What Are Lazy Connections?

When enabled, lazy connections allow the NetBird agent to:

  • Establish peer-to-peer connections only when needed (e.g., when pinging a remote peer).
  • Monitor peer activity and automatically disconnect peers that remain inactive and unreachable for a specified time.
  • Keep critical peers (such as excluded peers) always connected to ensure uninterrupted communication.

This feature is especially useful in large-scale deployments or resource-constrained environments, where maintaining full-mesh, permanent connections to all peers is unnecessary and inefficient.

How Automatic Disconnection Works

Once a connection between two peers is established, it will remain open only if there is ongoing traffic from the remote peer. If no traffic is received for 15 minutes, the connection will be closed — even if the remote peer is still reachable.

Enabling Lazy Connections on agent

Lazy connections are disabled by default. You can enable Lazy Connections using the following environment variable:

export NB_ENABLE_EXPERIMENTAL_LAZY_CONN=true

Or pass the flag directly via the CLI when running the agent:

netbird up --enable-lazy-connection

Enabling Lazy Connections in the NetBird Dashboard

The lazy connection feature can also be configured through the NetBird Dashboard. Here’s how it works once the setting is updated:

Setting enabled:

  • The client’s lazy connection manager is now active. Existing peer connections and ongoing connection attempts will remain unchanged for one hour. After that, any connection that couldn't be established due to unavailable remote peers will transition to an idle state.

Setting disabled:

  • The lazy connection manager is now disabled. The client will immediately attempt to establish connections with all remote peers.

Get started