Skip to main content

Configure initial peers

You need to manually configure the initial peers of nodes within the same swarm if mDNS is disabled on your devices or network, or if you are running Actyx on Docker.

Instead of automatically discovering other nodes via mDNS, your node will additionally try to reach other node(s) under the address(es) you configured after it starts.

Set up a discovery helper node

If you are not using fixed IP addresses, or your swarm consists of more than a few nodes, manually configuring all connections between nodes gets very complex and needs to be frequently updated. Therefore, we recommend setting up a central discovery helper node for production deployments. Check out this guide for more information.

Manually configure your nodes' initial peers

You can configure nodes in your swarm with each other's address as follows:

In this example, the node that should initiate the connection after startup has the IP address, the node that it should connect to has

1. Get the peer ID of the node you want to connect to by running ax nodes inspect:

ax nodes inspect
PeerId: 12D3KooWSgvc3hzrsuExYazNDB1BU3gevUPTzaumnwHWv5yFBNzH
| 12D3KooWNHvaVdcqoYCRTWURzC4gaZQBA7XjtSeSsWqcpErL5daL | /ip4/ |

In the above example output, you can see that the peer ID with IP address is 12D3KooWSgvc3hzrsuExYazNDB1BU3gevUPTzaumnwHWv5yFBNzH.

2. Configure the initialPeerssetting

You configure initialPeers in the following format: /ip4/<IP address>/tcp/<swarm port>/p2p/<peer ID>; the IP address of the node that you want to connect to, the swarm port (4001 unless configured differently), and the peer ID that you found out above.

You can configure the initialPeers by running [ax settings set](/docs/reference/cli/settings/set):

ax settings set /swarm/initialPeers [/ip4/]

For more information on how nodes discover and connect to each other, please check out our conceptual guide on discovery.