Js-ipfs Connect two Node.js instances with swarm.connect()

I’m running two IPFS instances in a Node.js server that I both control and both of them are behind a NAT.

[Node.js] <-----> [Node.js]

The IPFS config looks like this on both sides

this.ipfs = await create({
relay: { enabled: true, hop: { enabled: true, active: true } },
repo: “./ipfs”,
EXPERIMENTAL: { pubsub: true,},

When I start the server I get

Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip4/

I have not been able to connect the two nodes via


Can someone give me detailed instructions how I have to configure both nodes so that they can connect to each other?