Reputation: 31
I've been running my code successfully for the last two weeks. I've been able to connect to mongo just fine, and I had millions of items stored in my mongo database - my data folder is just over 3 GB. However today, my code failed with this error:
{ MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
at Timeout.waitQueueMember.timer.setTimeout [as _onTimeout] (C:\Users\User\Documents\node\node_modules\mongodb\lib\core\sdam\topology.js:430:30)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
name: 'MongoServerSelectionError',
reason:
TopologyDescription {
type: 'Single',
setName: null,
maxSetVersion: null,
maxElectionId: null,
servers: Map { 'localhost:27017' => [ServerDescription] },
stale: false,
compatible: true,
compatibilityError: null,
logicalSessionTimeoutMinutes: null,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
commonWireVersion: null } }
This error would happen every time I restarted the code. I tried restarting mongod from the console, and now the code runs, but ALL my database collections are now empty! The data folder is still 3GB so it looks like everything is still there. I don't know what has happened, because I haven't changed my code over the last 2 weeks and suddenly it is not working. I would love some help!
edit: this is the response I got when restarting the mongod server. I don't understand what it means:
2020-06-29T15:40:37.581+0100 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-06-29T15:40:37.584+0100 I CONTROL [initandlisten] MongoDB starting : pid=14532 port=27017 dbpath=C:\data\db\ 64-bit host=asus-laptop
2020-06-29T15:40:37.584+0100 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2020-06-29T15:40:37.585+0100 I CONTROL [initandlisten] db version v4.0.9
2020-06-29T15:40:37.585+0100 I CONTROL [initandlisten] git version: fc525e2d9b0e4bceff5c2201457e564362909765
2020-06-29T15:40:37.585+0100 I CONTROL [initandlisten] allocator: tcmalloc
2020-06-29T15:40:37.586+0100 I CONTROL [initandlisten] modules: none
2020-06-29T15:40:37.587+0100 I CONTROL [initandlisten] build environment:
2020-06-29T15:40:37.587+0100 I CONTROL [initandlisten] distmod: 2008plus-ssl
2020-06-29T15:40:37.587+0100 I CONTROL [initandlisten] distarch: x86_64
2020-06-29T15:40:37.588+0100 I CONTROL [initandlisten] target_arch: x86_64
2020-06-29T15:40:37.588+0100 I CONTROL [initandlisten] options: {}
2020-06-29T15:40:37.591+0100 I STORAGE [initandlisten] Detected data files in C:\data\db\ created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-06-29T15:40:37.592+0100 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=15847M,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),
2020-06-29T15:40:37.721+0100 I STORAGE [initandlisten] WiredTiger message [1593441637:721516][14532:140731272224336], txn-recover: Main recovery loop: starting at 8/9088 to 9/256
2020-06-29T15:40:37.819+0100 I STORAGE [initandlisten] WiredTiger message [1593441637:819111][14532:140731272224336], txn-recover: Recovering log 8 through 9
2020-06-29T15:40:37.873+0100 I STORAGE [initandlisten] WiredTiger message [1593441637:873160][14532:140731272224336], txn-recover: Recovering log 9 through 9
2020-06-29T15:40:37.918+0100 I STORAGE [initandlisten] WiredTiger message [1593441637:918201][14532:140731272224336], txn-recover: Set global recovery timestamp: 0
2020-06-29T15:40:37.939+0100 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-06-29T15:40:37.949+0100 I CONTROL [initandlisten]
2020-06-29T15:40:37.949+0100 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-06-29T15:40:37.950+0100 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-06-29T15:40:37.950+0100 I CONTROL [initandlisten]
2020-06-29T15:40:37.951+0100 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2020-06-29T15:40:37.952+0100 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2020-06-29T15:40:37.952+0100 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2020-06-29T15:40:37.953+0100 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2020-06-29T15:40:37.953+0100 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2020-06-29T15:40:37.953+0100 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2020-06-29T15:40:37.953+0100 I CONTROL [initandlisten]
2020-06-29T15:40:38.331+0100 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'
2020-06-29T15:40:38.334+0100 I NETWORK [initandlisten] waiting for connections on port 27017
2020-06-29T15:40:46.979+0100 I NETWORK [listener] connection accepted from 127.0.0.1:58942 #1 (1 connection now open)
2020-06-29T15:40:46.983+0100 I NETWORK [conn1] received client metadata from 127.0.0.1:58942 conn1: { driver: { name: "nodejs", version: "3.5.8" }, os: { type: "Windows_NT", name: "win32", architecture: "x64", version: "10.0.18362" }, platform: "'Node.js v10.15.1, LE (legacy)" }
2020-06-29T15:41:40.594+0100 I NETWORK [conn1] end connection 127.0.0.1:58942 (0 connections now open)
2020-06-29T15:41:41.775+0100 I NETWORK [listener] connection accepted from 127.0.0.1:59022 #2 (1 connection now open)
2020-06-29T15:41:41.779+0100 I NETWORK [conn2] received client metadata from 127.0.0.1:59022 conn2: { driver: { name: "nodejs", version: "3.5.8" }, os: { type: "Windows_NT", name: "win32", architecture: "x64", version: "10.0.18362" }, platform: "'Node.js v10.15.1, LE (legacy)" }
Upvotes: 1
Views: 1446
Reputation: 31
OK, I fixed it. For some reason, my data was stored in C:\Program Files\MongoDB\Server\4.0\data rather than \data\db. I don't know how this happened, but I've changed the directory. Still don't know why it decided to fail today, when it's been running fine all of the last two weeks. Leaving this here in case it helps others!
Upvotes: 2