Unable to connect to mongo server - mongodb

Im using mongoDb V 3.4 and trying to start the server but it says
C:\Users\gokul ram>mongo
MongoDB shell version v3.4.10
connecting to: mongodb://127.0.0.1:27017
2017-11-18T09:25:27.061+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017 after 5000ms milliseconds, giving up.
2017-11-18T09:25:27.062+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:237:13
#(connect):1:6
exception: connect failed
I also tried with --dbpath command, but it is waiting for connection for long time, still not getting connected
C:\Program Files\MongoDB\Server\3.4\bin>mongod --dbpath "C:/data/db"
2017-11-18T09:36:03.368+0530 I CONTROL [initandlisten] MongoDB starting : pid=4660 port=27017 dbpath=C:/data/db 64-bit host=GOK_RAM
2017-11-18T09:36:03.370+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2017-11-18T09:36:03.370+0530 I CONTROL [initandlisten] db version v3.4.10
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] git version: 078f28920cb24de0dd479b5ea6c66c644f6326e9
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] allocator: tcmalloc
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] modules: none
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] build environment:
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] distmod: 2008plus-ssl
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] distarch: x86_64
2017-11-18T09:36:03.372+0530 I CONTROL [initandlisten] target_arch: x86_64
2017-11-18T09:36:03.372+0530 I CONTROL [initandlisten] options: { storage: { dbPath: "C:/data/db" } }
2017-11-18T09:36:03.375+0530 I - [initandlisten] Detected data files in C:/data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-11-18T09:36:03.376+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1509M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-11-18T09:36:04.096+0530 I CONTROL [initandlisten]
2017-11-18T09:36:04.097+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-11-18T09:36:04.097+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-11-18T09:36:04.098+0530 I CONTROL [initandlisten]
2017-11-18T09:36:04.098+0530 I CONTROL [initandlisten] Hotfix KB2731284 or later update is not installed, will zero-out data files.
2017-11-18T09:36:04.098+0530 I CONTROL [initandlisten]
2017-11-18T09:36:05.880+0530 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'
2017-11-18T09:36:05.882+0530 I NETWORK [thread1] waiting for connections on port 27017
Is that problem with the mongo db version or my configurations? Any faced the same issue please help me!! Thanks in advance

First: navigate to C:\Program Files\MongoDB\Server\3.4\bin\ and run mongod.exe this will start the server .
second : in a new cmd typein mongo
this might work

You first need to start the mongo server using 'mongod.exe' command and set 'data\db' as dbpath where the data will be stored. Make sure the folders are created before running the command.
adding C:\Program Files\MongoDB\Server\3.4\bin\ to your environment variable 'PATH' will be beneficial.
To run the server type the following command in cmd prompt:
mongod --dbpath = C:\data\db
The server should run with default settings at port 27017
To connect to the server, open another cmd prompt and execute the 'mongo.exe' command. This should work.
Else you can try specifying the port number "mongo --port 27017"

First
We Need to Start the mongo server with --dbpath command
Next open seperate command window,
Set path to mongo bin and use mongo.exe command
Then you can start accesing mongo server.

Related

Error: couldn't connect to server 127.0.0.1:27017 even though I am running mongod

MongoDB shell version v4.2.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-05-02T19:00:36.477-0500 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
2020-05-02T19:00:36.483-0500 F - [main] exception: connect failed
2020-05-02T19:00:36.483-0500 E - [main] exiting with code 1
That is the error that I am getting after running Mongo and this is the response that I get after running mongod
2020-05-02T19:00:34.303-0500 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] MongoDB starting : pid=3964 port=27017 dbpath=/data/db 64-bit host=Mateos-MBP.attlocal.net
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] db version v4.2.3
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] allocator: system
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] modules: none
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] build environment:
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] distarch: x86_64
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] target_arch: x86_64
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] options: {}
2020-05-02T19:00:34.310-0500 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2020-05-02T19:00:34.310-0500 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2020-05-02T19:00:34.313-0500 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-05-02T19:00:34.313-0500 I CONTROL [initandlisten] now exiting
2020-05-02T19:00:34.313-0500 I CONTROL [initandlisten] shutting down with code:100
I have looked at multiple other questions and still can't seem to figure it out any help would be appreciated.
Create a directory /data/db and give permission to the MongoDB user so that MongoDB can access it. To create the directory:
sudo mkdir -p /data/db
To change owner:
sudo chown -R $USER /data/db
I followed this simple steps
Open your task manager if on windows
go to services -> go to MongoDB on services list provided
left click to highlight then down below click
->open services
on the list provided find MongoDB server
left click to highlight
click on the green play button to start the mongoDbServer
wait for a while
run your command again it will work
Open your task manager>services>MongoDB>"right-click and start the server"
It's obvious, that the MongoDB startup failed.
2020-05-02T19:00:34.310-0500 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
That's why you can't connect it. Because it's never startup. You can try to fix the MongoDB startup issue, then try to log in through CMD to make sure it's ok.

MongoDB shutting down with code:12

I have saved my data yesterday, but when I tried to open my MongoDB via command Prompt and fire the command mongod its throwing out the following messages
>C:\mongodb\bin>mongod
>2018-07-20T16:21:25.350+0530 I CONTROL [main] Automatically disabling TLS 1.0, >to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
>2018-07-20T16:21:25.842+0530 I CONTROL [initandlisten] MongoDB starting : >pid=13544 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-4H7RM2O
>2018-07-20T16:21:25.842+0530 I CONTROL [initandlisten] targetMinOS: Windows >7/Windows Server 2008 R2
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] db version v4.0.0
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] git version: >3b07af3d4f471ae89e8186d33bbb1d5259597d51
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] allocator: tcmalloc
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] modules: none
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] build environment:
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] distmod: 2008plus->ssl
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] distarch: x86_64
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] target_arch: x86_64
>2018-07-20T16:21:25.844+0530 I CONTROL [initandlisten] options: {}
>2018-07-20T16:21:25.844+0530 I STORAGE [initandlisten] exception in >initAndListen: NonExistentPath: Data directory C:\data\db\ not found., >terminating
>2018-07-20T16:21:25.844+0530 I CONTROL [initandlisten] now exiting
>2018-07-20T16:21:25.844+0530 I CONTROL [initandlisten] shutting down with >code:100
>
**Here is the command Prompt output when I fire mongo command**
<C:\mongodb\bin>mongo
<MongoDB shell version v4.0.0
<connecting to: mongodb://127.0.0.1:27017
<2018-07-20T16:28:01.594+0530 E QUERY [js] Error: couldn't connect to server <127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to <127.0.0.1:27017 :: caused by :: No connection could be made because the target <machine actively refused it. :
<connect#src/mongo/shell/mongo.js:251:13
<#(connect):1:6
<exception: connect failed
**This is my log file which is showing error =shutting down with code:12 **
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** WARNING: Access >control is not enabled for the database.
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** Read and >write access to data and configuration is unrestricted.
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten]
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** WARNING: This server >is bound to localhost.
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** Remote >systems will be unable to connect to this server.
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** Start the >server with --bind_ip <address> to specify which IP
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** addresses it >should serve responses from, or with --bind_ip_all to
>2018-07-20T15:43:37.426+0530 I CONTROL [initandlisten] ** bind to all >interfaces. If this behavior is desired, start the
>2018-07-20T15:43:37.426+0530 I CONTROL [initandlisten] ** server with >--bind_ip 127.0.0.1 to disable this warning.
>2018-07-20T15:43:37.426+0530 I CONTROL [initandlisten]
>2018-07-20T15:43:40.388+0530 I FTDC [initandlisten] Initializing full-time >diagnostic data capture with directory 'C:/mongodb/data/db/diagnostic.data'
>2018-07-20T15:43:40.499+0530 I NETWORK [initandlisten] waiting for connections >on port 27017
>2018-07-20T15:45:42.106+0530 I CONTROL [thread1] Ctrl-C signal
>2018-07-20T15:45:42.106+0530 I CONTROL [consoleTerminate] got CTRL_C_EVENT, >will terminate after current cmd ends
>2018-07-20T15:45:42.106+0530 I NETWORK [consoleTerminate] shutdown: going to >close listening sockets...
>2018-07-20T15:45:42.325+0530 I CONTROL [consoleTerminate] Shutting down free >monitoring
>2018-07-20T15:45:42.326+0530 I FTDC [consoleTerminate] Shutting down full->time diagnostic data capture
>2018-07-20T15:45:42.334+0530 I STORAGE [consoleTerminate] WiredTigerKVEngine >shutting down
>2018-07-20T15:45:45.543+0530 I STORAGE [consoleTerminate] shutdown: removing fs >lock...
>2018-07-20T15:45:45.543+0530 I CONTROL [consoleTerminate] now exiting
>2018-07-20T15:45:45.543+0530 I CONTROL [consoleTerminate] shutting down with >code:12
I have ensured that my data path is correct but unable to solve this problem.
Try below:
Mac: Documents/mongodb/bin/mongod --dbpath Documents/data/db/
Window: "C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath d:\test\mongodb\data
You just need to set db path.
You can set storage db path to the config file: Check this
And check this for window installation.
If you're using Linux just give increased permission to the storage file and restart mongodb it will work. Default storage file will be var/lib/mongodb. To give increased permissions use : chmod 777 mongod.

Mongodb Couldn't connect to local server

When I tried to connect to Mongodb locally, following error occurred.
MongoDB shell version v3.6.4
connecting to: mongodb://127.0.0.1:27017
2018-05-07T21:34:02.181+0545 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017 after 5000ms milliseconds, giving up.
2018-05-07T21:34:02.181+0545 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
I went through some solution in the internet and some of them told that try to run mongod first in one terminal and after that run mongo in another terminal. I'm using windows and I did this process in my command prompt.
When I tried to run mongod at first then following error is encountered -
2018-05-07T08:53:18.307-0700 I CONTROL [initandlisten] MongoDB starting : pid=4964 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-8E9NTFH
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] db version v3.6.4
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] git version: d0181a711f7e7f39e60b5aeb1dc7097bf6ae5856
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2o-fips 27 Mar 2018
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] allocator: tcmalloc
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] modules: none
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] build environment:
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] distmod: 2008plus-ssl
2018-05-07T08:53:18.309-0700 I CONTROL [initandlisten] distarch: x86_64
2018-05-07T08:53:18.309-0700 I CONTROL [initandlisten] target_arch: x86_64
2018-05-07T08:53:18.309-0700 I CONTROL [initandlisten] options: {}
2018-05-07T08:53:18.309-0700 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found., terminating
2018-05-07T08:53:18.309-0700 I CONTROL [initandlisten] now exiting
2018-05-07T08:53:18.309-0700 I CONTROL [initandlisten] shutting down with code:100
I tried to uninstall and reinstall mongodb but it get stocked here. Need your help.
Mongod does not start because the data path does not exist or is not accessible.
exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found
Creating the directory should fix the issue.

Rails Exception Mongo::Error::NoServerAvailable

I want to use MongoDB with my Rails app.
The error is not uncommon but none of the suggestions has worked for me.
I've installed mongodb using homebrew and followed the folowing the steps for same
brew update
brew install mongodb
sudo mkdir -p /data/db
sudo chmod 777 /data/db
brew tap homebrew/services
I use brew services start mongodb to start my mongodb server and get the following response
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] MongoDB starting : pid=39164 port=27017 dbpath=/data/db 64-bit host=C168s-iMac.local
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] db version v3.6.2
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] allocator: system
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] modules: none
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] build environment:
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] distarch: x86_64
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] target_arch: x86_64
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] options: {}
2018-02-08T12:27:59.089+0530 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-02-08T12:27:59.089+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3584M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2018-02-08T12:28:01.222+0530 I STORAGE [initandlisten] WiredTiger message [1518073081:222686][39164:0x7fffa9db0340], txn-recover: Main recovery loop: starting at 2/18944
2018-02-08T12:28:01.330+0530 I STORAGE [initandlisten] WiredTiger message [1518073081:330012][39164:0x7fffa9db0340], txn-recover: Recovering log 2 through 3
2018-02-08T12:28:01.442+0530 I STORAGE [initandlisten] WiredTiger message [1518073081:442109][39164:0x7fffa9db0340], txn-recover: Recovering log 3 through 3
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten]
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten]
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten]
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten]
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2018-02-08T12:28:02.572+0530 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2018-02-08T12:28:02.572+0530 I NETWORK [initandlisten] waiting for connections on port 27017
2018-02-08T12:28:09.302+0530 I NETWORK [listener] connection accepted from 127.0.0.1:51073 #1 (1 connection now open)
2018-02-08T12:28:09.302+0530 I NETWORK [conn1] received client metadata from 127.0.0.1:51073 conn: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.6.2" }, os: { type: "Darwin", name: "Mac OS X", architecture: "x86_64", version: "17.2.0" } }
Along with this I also start mongo
cd /usr/local/bin
mongod
which starts as expected.
I created my rails app without the ActiveRecord and used mongiod gem. Next i created the config file using rails g mongoid:config and added Mongoid.load! './config/mongoid.yml' in application.rb file so the config file is loaded.
The content for mongoid.yml is
development:
clients:
default:
database: mongo_db_demo_development
hosts:
- localhost:27017
test:
clients:
default:
database: mongo_db_demo_test
hosts:
- localhost:27017
options:
read:
mode: :primary
max_pool_size: 1
I created my scaffold for Person and the model was created as expected using include Mongoid::Document. I went ahead and used the index of person as my root_path.
When i run the rails server, I get the following error
ActionView::Template::Error (No server is available matching preference: # using server_selection_timeout=30 and local_threshold=0.015):
I know its an exception by rails but cant seem to resolve it for hours now.
I referred this tutorial to get started. The weird thing is that I was successful to set up the app in accessing it and the next day it crashed with this error without any changes. I'm able to access the books's new page /books/new but cant seem to save it, hence making it clear that the app is unable to access the database.
I've since uninstalled mongodb twice wondering if the installation has some problem but cant seem to figure out whats wrong.
I understand there are many similar questions but none to resolve my issue. I don't understand what I'm missing and going wrong. Any help is appreciated.
Thanks
Update
I was somehow able to run another project that had active record and mongodb in it. Here is the same. I was successful in saving the data to the post model proving that the mongod and mongo are running and the setup is done correctly. Which means that I'm missing something in my app configuration but yet, I've no clue.

MongoError: failed to connect to server [localhost:27017] on first connect

I have paid a membership and downloaded this project. After npm install and node app.js, it returns the following error:
Does anyone know what's wrong?
/Users/Thomas/Desktop/mean-stack-tutorial-01$ node app.js
/Users/Thomas/Desktop/mean-stack-tutorial-01/node_modules/mongodb/lib/server.js:265
process.nextTick(function() { throw err; })
^
MongoError: failed to connect to server [localhost:27017] on first connect
at Pool.<anonymous> (/Users/Thomas/Desktop/mean-stack-tutorial-01/node_modules/mongodb-core/lib/topologies/server.js:325:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection.<anonymous> (/Users/Thomas/Desktop/mean-stack-tutorial-01/node_modules/mongodb-core/lib/connection/pool.js:270:12)
at Connection.g (events.js:292:16)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:191:7)
at Socket.<anonymous> (/Users/Thomas/Desktop/mean-stack-tutorial-01/node_modules/mongodb-core/lib/connection/connection.js:173:49)
at Socket.g (events.js:292:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1281:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Edit 1: Following the comments, I just installed mongo via brew, and did brew services start mongodb and then mongo:
/Users/Thomas$ mongo
MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.1
Server has startup warnings:
2017-01-12T19:53:01.868+0800 I CONTROL [initandlisten]
2017-01-12T19:53:01.869+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-01-12T19:53:01.869+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-01-12T19:53:01.869+0800 I CONTROL [initandlisten]
Then I did
/Users/Thomas$ mongod -httpinterface --dbpath /Users/Thomas/Desktop/MongoDB/db
2017-01-12T20:14:05.620+0800 I CONTROL [initandlisten] MongoDB starting : pid=47356 port=27017 dbpath=/Users/Thomas/Desktop/MongoDB/db 64-bit host=Pro.local
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] db version v3.4.1
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] git version: 5e103c4f5583e2566a45d740225dc250baacfbd7
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2j 26 Sep 2016
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] allocator: system
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] modules: none
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] build environment:
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] distarch: x86_64
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] target_arch: x86_64
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] options: { storage: { dbPath: "/Users/Thomas/Desktop/MongoDB/db" } }
2017-01-12T20:14:05.657+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3584M,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-01-12T20:14:14.108+0800 I CONTROL [initandlisten]
2017-01-12T20:14:14.108+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-01-12T20:14:14.108+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-01-12T20:14:14.108+0800 I CONTROL [initandlisten]
2017-01-12T20:14:14.108+0800 I CONTROL [initandlisten]
2017-01-12T20:14:14.109+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2017-01-12T20:14:15.390+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/Users/Thomas/Desktop/MongoDB/db/diagnostic.data'
2017-01-12T20:14:16.303+0800 I INDEX [initandlisten] build index on: admin.system.version properties: { v: 2, key: { version: 1 }, name: "incompatible_with_version_32", ns: "admin.system.version" }
2017-01-12T20:14:16.304+0800 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2017-01-12T20:14:16.406+0800 I INDEX [initandlisten] build index done. scanned 0 total records. 0 secs
2017-01-12T20:14:16.407+0800 I COMMAND [initandlisten] setting featureCompatibilityVersion to 3.4
2017-01-12T20:14:16.407+0800 I NETWORK [thread1] waiting for connections on port 27017
Then in another terminal, I did node app.js, which hangs (and does not print anything). Then I does http://localhost:28017 in a browser, it seems to work:
However, how could I see the website?
Edit 2:
The normal process is
install mongo
brew services start mongodb in a terminal
mongo & (assume we use the default folder /data/db/)
npm start
see e.g., bin/www for the port number, then use localhost:the_port_number in a browser
Update 2020 Feb 24:
It would be wise to stay tuned with it. Here is the link for latest library instruction:
https://docs.mongodb.com/manual/administration/install-community/
You haven't started your monogo database. first install mongo install mongo as per your OS https://docs.mongodb.com/v3.0/tutorial/
then follow instructions mentioned on this site:
https://docs.mongodb.com/v3.0/tutorial/getting-started-with-the-mongo-shell/
cd .
mongod --dbpath "any directory path to start your database "
and then start your node server. It will work fine.
Hope this helps!!
First open another terminal an run command mongod to start your mongoDB
Then again start you node server npm start or if you have "nodemon" then using nodemon
I think now everything will be fine it will show
Mongoose connected to mongodb://localhost/your_database
I had the same issue but it worked fine after restarting the service
service mongod start