Cannot assign request address (exit 48)

I’m trying to follow this tutorial on how to deploy a sharded cluster. I’m having a lot of trouble with the ports/IPs from AWS. I have the ConfigServer .conf file exactly as configured in the tutorial. The relevant log message is:

"msg": "Error setting up listener",
"attr": {
    "error": {
    "code": 9001,
    "codeName": "SocketException",
    "errmsg": "Cannot assign requested address"
    }
}

In the ‘bindIp’ line, I’ve attributed the Elastic IP associated with the instance. I’ve allowed all traffic from any IPv4 in its security group. I can ping to the elastic IP from this instance. However I still get this error.

What am I doing wrong?

The IP address you gave for bindIp may be invalid

I can’t set bindIp

1 Like

Thank you! If I understood that thread correctly, then I can only input local IPs on net.bindIP? The documentation says that you can put any IPv4/6 or logical DNS, though.

I tried placing an elastic IP associated with the instance, its IPv4, its DNS, etc… Nothing worked. I can ping to all these addresses just fine, though.

Whatever address you put will have to resolve to an ip address on the local machine. The OS cannot bind an ip it does not have on its interfaces.

hostname -I and ip addr list, among others, will list what ip addresses are available to the host.

Thank you! So you’re telling me server 1’s IP must be in the server 2’s IP list in order for it to be accessible in 2? How do I make these IPs available then?

After some manipulation, I’m now getting an error on the Router side: it cannot connect to the Config Server via its IP. This is what I place in a configuration file (just as in the tutorial):
sharding:
configDB: ConfigReplSet/PrivateIPv4:port

The port is defined in the Config server configuration file as well.
This is what I get in my logs:
“errorMessage”: “HostUnreachable: Error connecting to 172.31.36.243:27019 :: caused by :: Connection refused”

No I’m not. Your error is mongod binding a ip:port to listen for incoming tcp connections. It has nothing to do with any other service at this point. What I’m telling you is how to find what ip’s the mongod can bind to.

Right. So right now I seem to have the .conf files configured correctly, as I can check that the Router connects to the Config Server. The problem now is that I can’t seem to initiate a ReplicaSet on the ConfigServer. I will open this on another thread.
ConfigServer .conf file:

net:
  port: 27019
  bindIp: 0.0.0.0

And for the router:

net:
    port: 27020
    bindIp: <Private IPv4 Address>