python - Problems establishing connection with DB -


platform: linux.

i beginner of mongodb , pymongo. after installing pymongo, here simple test tried on ipython:

import pymongo client = pymongo.mongoclient(); # tried specify local host , port number db = client['mydb'] collections = db['temptables'] collections.insert({'a':'1'}) 

at point, chokes. , in end, spits out "error 111: connection refused" error. so, tried invoking mongodb straight terminal , still got error below [look @ far end]. so, searched bit , tried:

  1. removing lock ( sudo rm /var/lib/mongodb/mongod.lock ). turns out there no lock in first place.

  2. sudo mongod --repair

  3. i saw suggestion comment out host , port number config file. tried too, didn't work.

none of above worked.

this error see when try invoke mongodb command line.


017-08-17t15:25:30.265-0700 w network [thread1] failed connect 127.0.0.1:27017, in(checking socket error after poll), reason: connection refused 2017-08-17t15:25:30.265-0700 e query [thread1] error: couldn't connect server 127.0.0.1:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:237:13 @(connect):1:6

exception: connect failed

help, please.

your mongo server isn't running.

you can confirm executing sudo ps -ef | grep mongod

if have mongo installed , in path, can execute:

cd && mkdir -p ~/temp_mongo_db && mongod --dbpath=./temp_mongo_db 

this launch mongo , place database files in home directory under 'temp_mongo_db'.

finally, in new terminal window, execute sudo ps -ef | grep mongod again. you'll see mongod running.

if want run mongo in production, should configure managed systemd or other init system.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -