Cannot connect remotely to MongoDB on Azure. I get a connection using local host but I cannot create a socket using the public IP Address

835 views
Skip to first unread message

James Martin

unread,
Feb 22, 2016, 2:02:16 AM2/22/16
to mongodb-user
I am unable to connect to an instance of MongoDB on our windows azure account no matter what I try.

Please see the startup log below.

2016-02-22T12:26:26.091+1000 I CONTROL  [main] Trying to start Windows service 'MongoDB'
2016-02-22T12:26:26.094+1000 I STORAGE  [thread1] Service running
2016-02-22T12:26:26.094+1000 I CONTROL  [initandlisten] MongoDB starting : pid=2908 port=27017 dbpath=c:\data\db 64-bit host=pcq-cs-xxx-xxx
2016-02-22T12:26:26.094+1000 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2016-02-22T12:26:26.094+1000 I CONTROL  [initandlisten] db version v3.2.3
2016-02-22T12:26:26.095+1000 I CONTROL  [initandlisten] git version: b326ba837cf6f49d65c2f85e1b70f6f31ece7937
2016-02-22T12:26:26.095+1000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1p-fips 9 Jul 2015
2016-02-22T12:26:26.095+1000 I CONTROL  [initandlisten] allocator: tcmalloc
2016-02-22T12:26:26.095+1000 I CONTROL  [initandlisten] modules: none
2016-02-22T12:26:26.095+1000 I CONTROL  [initandlisten] build environment:
2016-02-22T12:26:26.095+1000 I CONTROL  [initandlisten]     distmod: 2008plus-ssl
2016-02-22T12:26:26.095+1000 I CONTROL  [initandlisten]     distarch: x86_64
2016-02-22T12:26:26.095+1000 I CONTROL  [initandlisten]     target_arch: x86_64
2016-02-22T12:26:26.095+1000 I CONTROL  [initandlisten] options: { net: { bindIp: "40.126.xxx.xxx" }, service: true, storage: { dbPath: "c:\data\db", directoryPerDB: true }, systemLog: { destination: "file", logAppend: true, path: "c:\mongo\logs\log" } }
2016-02-22T12:26:26.096+1000 E NETWORK  [initandlisten] listen(): bind() failed errno:10049 The requested address is not valid in its context. for socket: 40.126.xxx.xxx:27017
2016-02-22T12:26:26.096+1000 E STORAGE  [initandlisten] Failed to set up sockets during startup.
2016-02-22T12:26:26.096+1000 I CONTROL  [serviceStopWorker] dbexit:  rc: 49

I have set the db and log folders according to instructions on the mongo db web site and stack overflow suggestions. I have double checked the Public IP Address is correct. Opened up ports in both the firewall and endpoints settings. I am able to login and see the database using robo mongo locally as well as getting a connection through the shell as indicated below.

2016-02-22T15:32:11.816+1000 I CONTROL  [initandlisten] targetMinOS: Windows 7/W
indows Server 2008 R2
2016-02-22T15:32:11.817+1000 I CONTROL  [initandlisten] db version v3.2.3
2016-02-22T15:32:11.817+1000 I CONTROL  [initandlisten] git version: b326ba837cf
6f49d65c2f85e1b70f6f31ece7937
2016-02-22T15:32:11.818+1000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL
 1.0.1p-fips 9 Jul 2015
2016-02-22T15:32:11.818+1000 I CONTROL  [initandlisten] allocator: tcmalloc
2016-02-22T15:32:11.819+1000 I CONTROL  [initandlisten] modules: none
2016-02-22T15:32:11.819+1000 I CONTROL  [initandlisten] build environment:
2016-02-22T15:32:11.819+1000 I CONTROL  [initandlisten]     distmod: 2008plus-ss
l
2016-02-22T15:32:11.820+1000 I CONTROL  [initandlisten]     distarch: x86_64
2016-02-22T15:32:11.820+1000 I CONTROL  [initandlisten]     target_arch: x86_64
2016-02-22T15:32:11.820+1000 I CONTROL  [initandlisten] options: {}
2016-02-22T15:32:11.830+1000 I -        [initandlisten] Detected data files in C
:\data\db\ created by the 'wiredTiger' storage engine, so setting the active sto
rage engine to 'wiredTiger'.
2016-02-22T15:32:11.831+1000 I STORAGE  [initandlisten] wiredtiger_open config:
create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=fals
e,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snapp
y),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),stati
stics_log=(wait=0),
2016-02-22T15:32:48.146+1000 I NETWORK  [HostnameCanonicalizationWorker] Startin
g hostname canonicalization worker
2016-02-22T15:32:48.146+1000 I FTDC     [initandlisten] Initializing full-time d
iagnostic data capture with directory 'C:/data/db/diagnostic.data'
2016-02-22T15:32:48.149+1000 I NETWORK  [initandlisten] waiting for connections
on port 27017
2016-02-22T15:33:08.410+1000 I NETWORK  [initandlisten] connection accepted from
 127.0.0.1:57717 #1 (1 connection now open)

The only thing I don't seem to be able to do is connect remotely. I understand that error 10049 is saying that the requested address is not valid in this context. I have also tried running mongod with a config file specifying more than one IP address as below.

storage:
    dbPath: "/data/db"
    directoryPerDB: true
    journal: 
        enabled: true
systemLog:
    destination: file
    path: "/Mongo/logs/mongodb.log"
    logAppend: true
    timeStampFormat: iso8601-utc
net: 
    bindIp: 40.126.xxx.xxx, 127.0.0.1
    port: 27017
    wireObjectCheck: true

Can anyone please guide me on what I may be missing? If I can connect using the shell and the localhost address but not the public IP address, is it that MongoDB can't use the public IP address that is set by Microsoft and I need to add something in the application.host files to re-map the IP Address. 
 

Wan Bachtiar

unread,
Mar 1, 2016, 7:40:12 AM3/1/16
to mongodb-user

bind() failed errno:10049 The requested address is not valid in its context. for socket: 40.126.xxx.xxx:27017

Hi James,

The error code 10049 is a Windows Sockets Error code. The requested address is not valid in its context. This normally results from an attempt to bind to an address that is not valid for the local computer.

You should check that your instance actually has the IP assignment of 40.126.xxx.xxx by using ipconfig command. If your IP address is not on the output list, then the IP address is invalid to bind to. i.e. You can’t bind to an external IP.

If the IP address is on the output list of ipconfig, then you may want to double check your network firewall settings.

As this is more of a networking question rather than MongoDB usage, you may get a faster response and a wider audience by posting a question on ServerFault or SuperUser.

Kind regards,

Wan.

Reply all
Reply to author
Forward
0 new messages