1

I have configured a mongodb on my server to accept remote connections.I commented the bind line in the /etc/mongod.conf, so the file looks like:

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
#  bindIp: 127.0.0.1

#processManagement:

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:

I configured the server to accept connections on port 27017 and as you can see there's no other security measures like password.

When I try to connect to the server's port 27017, everything goes well, but after 2 or 3 minutes (4 or 5 queries to mongo server), the connection is suddenly lost and server is not reachable then.

Cannot connect to the MongoDB at ****:27017.

Error:
Network is unreachable.

Server is reachable and I can telnet other ports and make an ssh connection to server, but till I reset my OS, I can not reach the port 27017 again. The problem is only occurring on my OS and others don't have the problem, So it's probably my OS's problem. But I'm confused about it. What can be the problem?

5
  • Change the IP of your OS and see if it still happens. If so, then perhaps the IP address of that machine was blacklisted per unsuccessful login attempts or something. Commented Nov 1, 2017 at 11:57
  • @TheFurryITSnuggleBuddy Changing Ip solves the problem for a while and then the same thing happens, but there's no login required, so there can not be any attempts that end up being unsuccessful...
    – Aidin.T
    Commented Nov 1, 2017 at 12:16
  • I think you need to keep digging man. Turn on verbose logs on server and search for the most recent IP that gets blocked and see if the "verbose" logging gives any further clue such as username being used e.g. root, etc. Something may ring a bell but do some Googling on your findings and read over various posts. Do some more digging on it and let me know if you find anything further or interesting. Hopefully you have some more IPs to burn thru but find what is blocking it too and remove like Fail2Ban, IPTable, etc. Commented Nov 1, 2017 at 12:41
  • 1
    See System Logging section docs.mongodb.com/manual/reference/configuration-options. Looks like you may need to add verbosity: 5 but double-check and confirm. Commented Nov 1, 2017 at 12:43
  • @TheFurryITSnuggleBuddy I found it. log showed nothing about my computer trying to connect, but my colleague's computer could connect easily. So while an ip can connect to a server, the same ip (as I and my colleague are behind a NAT server) can not connect. logical reasoning: my ip is not the same. So it turned out I was tunneling via a kerio vpn which I didn't know about. I disconnected the vpn and everything is ok. Thanks for your comments.
    – Aidin.T
    Commented Nov 1, 2017 at 14:13

1 Answer 1

0

So, The Furry IT Snuggle Buddy's comment helped me find out what was wrong with my OS. log showed nothing about my computer trying to connect, but my colleague's computer could connect easily. So while an ip can connect to a server, the same ip (as I and my colleague are behind a NAT server) can not connect. logical reasoning: my ip is not the same. So it turned out I was tunneling via a kerio vpn which I didn't know about. I disconnected the vpn and everything is ok.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .