title: MongoDB returning exit code 49
body: <p>I installed mongodb and then I created a service to run it.
  Starting the service works without problem but while trying to shutdown it, I get an error code by windows. I checked the log file and this is what I get:</p>
  <p><code>2017-02-23T08:36:51.518+0100 I CONTROL [serviceStopWorker] shutting down with code:49</code>
  <a href="https://i.stack.imgur.com/DWywU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DWywU.png" alt="enter image description here" /></a></p>
  <p>(Translation)
  Error 1067: the process terminated unexpectedly</p>
  <p><strong>Service path:</strong></p>
  <p><code>&quot;C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe&quot; --config &quot;C:\Program Files\MongoDB\Server\3.4\bin\mongod.cfg&quot; --service</code></p>
  <p><strong>mongodb.cfg</strong></p>
  <pre><code>systemLog:
      destination: file
      path: &quot;C:\\data\\log\\mongod.log&quot;
  storage:
      dbPath: &quot;C:\\data\\db&quot;
  </code></pre>
  <p>I tried to find the error codes but it doesn't appear.</p>
  <p><a href="https://docs.mongodb.com/manual/reference/exit-codes/" rel="nofollow noreferrer">https://docs.mongodb.com/manual/reference/exit-codes/</a></p>
  <p>The only reference I could find is this. A test with questions/answers about exit codes. (Question #7)</p>
  <p><a href="http://www.sanfoundry.com/mongodb-questions-answers-exit-codes-statutes/" rel="nofollow noreferrer">http://www.sanfoundry.com/mongodb-questions-answers-exit-codes-statutes/</a></p>
  <pre><code>7. 49 code is returned by mongod from _________ Service control Manager.
  a) Linux
  b) Windows
  c) Ubuntu
  d) All of the mentioned
  View Answer
  
  Answer:a
  Explanation:Custom read preferences and write concerns evaluate tags sets in different ways.
  </code></pre>
  <p>But I am on a Windows 7 machine. So that's quite odd.</p>
  <p><em><strong>Windows 7 x64 SP1</strong></em></p>
  <p><em><strong>MongoDB 3.4.2</strong></em></p>
  <p>Any idea?</p>
  <p><em><strong>LOG</strong></em></p>
  <blockquote>
  <p>2017-02-23T08:36:48.484+0100 I CONTROL  [main] Trying to start Windows service 'MongoDB'</p>
  <p>2017-02-23T08:36:48.485+0100 I CONTROL  [initandlisten] MongoDB starting : pid=17856 port=27017 dbpath=C:\data\db 64-bit host=FRAmdsWS430</p>
  <p>2017-02-23T08:36:48.485+0100 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2</p>
  <p>2017-02-23T08:36:48.485+0100 I CONTROL  [initandlisten] db version v3.4.2</p>
  <p>2017-02-23T08:36:48.485+0100 I CONTROL  [initandlisten] git version: 3f76e40c105fc223b3e5aac3e20dcd026b83b38b</p>
  <p>2017-02-23T08:36:48.485+0100 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips  22 Sep 2016</p>
  <p>2017-02-23T08:36:48.485+0100 I CONTROL  [initandlisten] allocator: tcmalloc</p>
  <p>2017-02-23T08:36:48.485+0100 I CONTROL  [initandlisten] modules: none</p>
  <p>2017-02-23T08:36:48.486+0100 I CONTROL  [initandlisten] build environment:</p>
  <p>2017-02-23T08:36:48.486+0100 I CONTROL  [initandlisten]     distmod: 2008plus-ssl</p>
  <p>2017-02-23T08:36:48.486+0100 I CONTROL  [initandlisten]     distarch: x86_64</p>
  <p>2017-02-23T08:36:48.486+0100 I CONTROL  [initandlisten]     target_arch: x86_64</p>
  <p>2017-02-23T08:36:48.486+0100 I CONTROL  [initandlisten] options: { config: &quot;C:\Program Files\MongoDB\Server\3.4\bin\mongod.cfg&quot;, service: true, storage: { dbPath: &quot;C:\data\db&quot; }, systemLog: { destination: &quot;file&quot;, path: &quot;C:\data\log\mongod.log&quot; } }</p>
  <p>2017-02-23T08:36:48.488+0100 I -        [initandlisten] Detected data files in C:\data\db created by the 'mmapv1' storage engine, so setting the active storage engine to 'mmapv1'.</p>
  <p>2017-02-23T08:36:48.497+0100 I JOURNAL  [initandlisten] journal dir=C:\data\db\journal</p>
  <p>2017-02-23T08:36:48.497+0100 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed</p>
  <p>2017-02-23T08:36:48.636+0100 I JOURNAL  [durability] Durability thread started</p>
  <p>2017-02-23T08:36:48.636+0100 I JOURNAL  [journal writer] Journal writer thread started</p>
  <p>2017-02-23T08:36:48.693+0100 I CONTROL  [initandlisten]</p>
  <p>2017-02-23T08:36:48.693+0100 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.</p>
  <p>2017-02-23T08:36:48.693+0100 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.</p>
  <p>2017-02-23T08:36:48.693+0100 I CONTROL  [initandlisten]</p>
  <p>2017-02-23T08:36:48.938+0100 W FTDC     [initandlisten] Failed to initialize Performance Counters for FTDC: WindowsPdhError: PdhExpandCounterPathW failed with 'Das angegebene Objekt wurde nicht auf dem Computer gefunden.' for counter '\Memory\Available Bytes'</p>
  <p>2017-02-23T08:36:48.938+0100 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'</p>
  <p>2017-02-23T08:36:48.940+0100 I NETWORK  [thread1] waiting for connections on port 27017</p>
  <p>2017-02-23T08:36:48.940+0100 I STORAGE  [initandlisten] Service running</p>
  <p>2017-02-23T08:36:51.412+0100 I CONTROL  [serviceShutdown] got SERVICE_CONTROL_STOP request from Windows Service Control Manager, will terminate after current cmd ends</p>
  <p>2017-02-23T08:36:51.412+0100 I NETWORK  [serviceShutdown] shutdown: going to close listening sockets...</p>
  <p>2017-02-23T08:36:51.412+0100 I NETWORK  [serviceShutdown] closing listening socket: 456</p>
  <p>2017-02-23T08:36:51.413+0100 I NETWORK  [serviceShutdown] shutdown: going to flush diaglog...</p>
  <p>2017-02-23T08:36:51.413+0100 I FTDC     [serviceShutdown] Shutting down full-time diagnostic data capture</p>
  <p>2017-02-23T08:36:51.413+0100 I STORAGE  [serviceShutdown] shutdown: waiting for fs preallocator...</p>
  <p>2017-02-23T08:36:51.413+0100 I STORAGE  [serviceShutdown] shutdown: final commit...</p>
  <p>2017-02-23T08:36:51.438+0100 I JOURNAL  [serviceShutdown] journalCleanup...</p>
  <p>2017-02-23T08:36:51.439+0100 I JOURNAL  [serviceShutdown] removeJournalFiles</p>
  <p>2017-02-23T08:36:51.439+0100 I JOURNAL  [serviceShutdown] old journal file will be removed: C:\data\db\journal\j._0</p>
  <p>2017-02-23T08:36:51.439+0100 I JOURNAL  [serviceShutdown] Terminating durability thread ...</p>
  <p>2017-02-23T08:36:51.516+0100 I JOURNAL  [journal writer] Journal writer thread stopped</p>
  <p>2017-02-23T08:36:51.516+0100 I JOURNAL  [durability] Durability thread stopped</p>
  <p>2017-02-23T08:36:51.516+0100 I STORAGE  [serviceShutdown] shutdown: closing all files...</p>
  <p>2017-02-23T08:36:51.518+0100 I STORAGE  [serviceShutdown] closeAllFiles() finished</p>
  <p>2017-02-23T08:36:51.518+0100 I STORAGE  [serviceShutdown] shutdown: removing fs lock...</p>
  <p>2017-02-23T08:36:51.518+0100 I CONTROL  [serviceShutdown] now exiting</p>
  <p>2017-02-23T08:36:51.518+0100 I CONTROL  [serviceStopWorker] shutting down with code:49</p>
  </blockquote>