I create my host like so:
host, err := libp2p.New(ctx, libp2p.ListenAddrStrings(fmt.Sprintf("/ip4/%s/tcp/%d", ipStr, port)),
libp2p.Identity(privateKey))
if err != nil {
logger.Log.Fatal("Could not create p2p host %s", err)
}
I used 0.0.0.0
locally to create the host and it worked. When I try this on my EC2 machine inside a docker container libp2p binds to an IP address that I can’t find in my AWS console. It’s not the ec2 public nor the private IP and can’t be found in the network interfaces.
If I pass the public or private IP the creation fails with following error:
FATAL Could not create p2p host failed to listen on any addresses: [listen tcp4 xx.xxx.xxx.xx:5500: bind: cannot assign requested address]
In my docker-compose file I configured the container port (5500) to be mapped to the host port (5500).
Any suggestion how to fix this?
Update:
Following the code from this issue: https://github.com/libp2p/go-libp2p/issues/460
The node now listens to 127.0.0.1:[randomport], [ip address, that I don’t know]:[randomport] and the ip and port I supplied. Still other nodes can’t connect. I opened the port 5500 on AWS.