Search code examples
tcplibp2p

libp2p node gives Error: connect ECONNREFUSED


I have a libp2p running inside a nodejs server.

From outside the docker I can connect to the node by using p2p addr: /ip4/127.0.0.1/tcp/3333/p2p/Q… so I know the libp2p node is up and listening and docker-proxy is connecting to the container on that port.

The port is open as

sudo ufw status

says:

To         Action From

3333      ALLOW  Anywhere 
3333 (v6) ALLOW  Anywhere (v6)

also:

 sudo netstat -plunt | grep 3333
tcp        0      0 0.0.0.0:3333           0.0.0.0:*               LISTEN      6539/docker-proxy   
tcp6       0      0 :::3333                :::*                    LISTEN      6545/docker-proxy 

But from any other computer I get connection refused by both a libp2p node and the ubuntu command:

nc -zvw10 ip-address 3333

What is wrong?

Thanks.


Solution

  • When creating the libp2p node the ip address must be 0.0.0.0 instead of 127.0.0.0 or the real server's ip.

    Then, when trying to remotely reach the libp2p node, the ip has to be that of the server (the one that ping your-domain.com returns)

    Imo 80% of development pain comes from too simple examples in the "documentation"