Lab2: configuration file cannot assign requested address

I set the configuration file as below:
dbPath: “/data/db”

path: “/data/mongofile.log”
destination: file

bindIp: localhost,
port: 27000

authorization: enabled
fork: true
pidFilePath: /data/
and when i start monod i get the below error

2019-02-23T23:55:31.418+0000 I CONTROL [initandlisten] options: { config: “/data/lab02.conf”, net: { bindIp: “localhost,”, port: 27000 }, processManagement: { fork: true, pidFilePath: “/data/” }, security: { authorization: “enabled” }, storage: { dbP
ath: “/data/db” }, systemLog: { destination: “file”, path: “/data/mongofile.log” } }
2019-02-23T23:55:31.419+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Cannot assign requested address

Is any other instance using same port?
ps -ef|grep -i mongo

1 Like

Hi mraafat,

Please check this post:


I tried the solution and I still receive the same error. Every time I run ifconfig, I see the IP. I’ve run netstat and both the IP and port are available.

typically code 48 indicates ‘something’ probably another instance of mongod is running on the port already.
there is a (subtle but important) difference between mongod and mongo the first starts the ‘daemon’ or service, the second is the ‘shell’ in which you will talk to the daemon. (Hey, this stuff is new to me - been working in Windows for decades. . .)

First, this thread is 22 days old. I suggest you start a new thread the next time.

Second, what are the error messages you are getting?

Did we start a new thread? I am also stuck on same problem, getting following error:

vagrant@m103:~$ mongod --port 27000 --dbpath data/db --bind_ip “,” --auth
2019-07-23T19:13:21.929+0000 I CONTROL [initandlisten] MongoDB starting : pid=8171 port=27000 dbpath=data/db 64-bit host=m103
2019-07-23T19:13:21.930+0000 I CONTROL [initandlisten] db version v3.6.12
2019-07-23T19:13:21.930+0000 I CONTROL [initandlisten] git version: c2b9acad0248ca06b14ef1640734b5d0595b55f1
2019-07-23T19:13:21.931+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2019-07-23T19:13:21.932+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-07-23T19:13:21.932+0000 I CONTROL [initandlisten] modules: enterprise
2019-07-23T19:13:21.932+0000 I CONTROL [initandlisten] build environment:
2019-07-23T19:13:21.933+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2019-07-23T19:13:21.934+0000 I CONTROL [initandlisten] distarch: x86_64
2019-07-23T19:13:21.935+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-07-23T19:13:21.935+0000 I CONTROL [initandlisten] options: { net: { bindIp: “,”, port: 27000 }, security: { authorization: “enabled” }, storage: { dbPath: “data/db” } }
2019-07-23T19:13:21.936+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Cannot assign requested address
2019-07-23T19:13:21.937+0000 I CONTROL [initandlisten] now exiting
2019-07-23T19:13:21.938+0000 I CONTROL [initandlisten] shutting down with code:48

The last message on this thread said

And now we are 4 months later. You should start a new thread when you have a new issue.

The most likely reason is that you already have a server listening to the requested address.

Hi @Afzal_53899,

You need to re-check the bind_ip parameter here. Please check you are using correct values as mentioned in the lab.

Please let me know, if you have any questions.