Pymongo.errors.ConnectionFailure: Failed to connect to localhost: 27017: [Errno 111] Connection refused

When I ran into its error, I removed mongod.lock from / var / lib / mongodb then I did mongod -repair This is how it listed all these things

Fri Mar 21 14:21:17.511 [initandlisten] MongoDB starting : pid=21182 port=27017 dbpath=/data/db/ 64-bit host=thara-Precision-T1600
Fri Mar 21 14:21:17.511 [initandlisten] db version v2.4.9
Fri Mar 21 14:21:17.511 [initandlisten] git version: 52fe0d21959e32a5bdbecdc62057db386e4e029c
Fri Mar 21 14:21:17.511 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Fri Mar 21 14:21:17.511 [initandlisten] allocator: tcmalloc
Fri Mar 21 14:21:17.511 [initandlisten] options: { repair: true }
Fri Mar 21 14:21:17.511 [initandlisten] exception in initAndListen: 10296 
*********************************************************************
 ERROR: dbpath (/data/db/) does not exist.
 Create this directory or give existing directory in --dbpath.
 See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
Fri Mar 21 14:21:17.511 dbexit: 
Fri Mar 21 14:21:17.511 [initandlisten] shutdown: going to close listening sockets...
Fri Mar 21 14:21:17.511 [initandlisten] shutdown: going to flush diaglog...
Fri Mar 21 14:21:17.511 [initandlisten] shutdown: going to close sockets...
Fri Mar 21 14:21:17.511 [initandlisten] shutdown: waiting for fs preallocator...
Fri Mar 21 14:21:17.511 [initandlisten] shutdown: closing all files...
Fri Mar 21 14:21:17.511 [initandlisten] closeAllFiles() finished
Fri Mar 21 14:21:17.511 dbexit: really exiting now

      

Still said pymongo.errors.ConnectionFailure: Failed to connect to localhost: 27017: [Errno 111] Connection refused

0


source to share


1 answer


As the error message says, mongod cannot find the db path. Either create a folder "/data/db"

in the root, or if you created it elsewhere, specify the path using a parameter --dbpath

, for example:



mongod --dbpath /data/db

      

+4


source







All Articles