couldn't connect to server localhost:27017, connection attempt failed

187 views
Skip to first unread message

Prashant Pokhriyal

unread,
Jun 29, 2018, 7:24:53 AM6/29/18
to mongodb-user

I'm not able to copy a database. It returns me following error:


>db.copyDatabase('testing_demo', 'testing')

{
	"ok" : 0,
	"errmsg" : "couldn't connect to server localhost:27017, connection attempt failed",
	"code" : 6,
	"codeName" : "HostUnreachable"
}


I don't know why it says localhost, I'm connecting to mongodb server having ip address 172.31.21.200


mongo --host 172.31.21.200



mongod.conf


# 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: 172.31.21.200


#processManagement:

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:



Output of mongo --version

MongoDB shell version v3.4.15
git version: 52e5b5fbaa3a2a5b1a217f5e647b5061817475f9
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1604
    distarch: x86_64
    target_arch: x86_64

Ramon Fernandez

unread,
Jun 29, 2018, 7:33:37 AM6/29/18
to mongod...@googlegroups.com
Your /etc/hosts as displayed in SERVER-35838 looks suspicious to me; I’d recommend you try setting it to

127.0.0.1 localhost
172.31.21.200 testing.dev

and try again.

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/a2c7474b-baed-4105-a1e8-6c3dfd3c3da0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages