title: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused mongodb
body: <p>I have 2 terminal windows, first to run the server, the second one to use as a client to connect to the db server.<br>
  I have successfully connected to my local mongoDB server.    </p>
  
  <p><strong>Terminal window 1</strong></p>
  
  <pre><code>bogdanmac:~ iliebogdanbarbulescu$ 
  bogdanmac:~ iliebogdanbarbulescu$ brew services start mongodb-community@4.2
  Service `mongodb-community` already started, use `brew services restart mongodb-community` to restart.
  </code></pre>
  
  <p>Unfortunately, I can not access the database from the <strong>client</strong>.   </p>
  
  <p><strong>Terminal window 2</strong></p>
  
  <pre><code>ilies-mbp:mongodb iliebogdanbarbulescu$ pwd
  /usr/local/var/mongodb
  ilies-mbp:mongodb iliebogdanbarbulescu$ ls
  WiredTiger              diagnostic.data
  WiredTiger.lock             index-1-454351138292104502.wt
  WiredTiger.turtle           index-3-454351138292104502.wt
  WiredTiger.wt               index-5-454351138292104502.wt
  WiredTigerLAS.wt            index-6-454351138292104502.wt
  _mdb_catalog.wt             journal
  collection-0-454351138292104502.wt  mongod.lock
  collection-2-454351138292104502.wt  sizeStorer.wt
  collection-4-454351138292104502.wt  storage.bson
  ilies-mbp:mongodb iliebogdanbarbulescu$ mongo
  MongoDB shell version v4.2.5
  connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&amp;gssapiServiceName=mongodb
  2020-04-16T17:13:02.269+0100 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-04-16T17:13:02.271+0100 F  -        [main] exception: connect failed
  2020-04-16T17:13:02.271+0100 E  -        [main] exiting with code 1
  ilies-mbp:mongodb iliebogdanbarbulescu$    
  </code></pre>
  
  <p><strong>Logs at /usr/local/var/log/mongodb/mongo.log</strong></p>
  
  <pre><code>2020-04-16T16:54:03.370+0100 I  CONTROL  [main] ***** SERVER RESTARTED *****
  2020-04-16T16:54:03.373+0100 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
  2020-04-16T16:54:03.385+0100 W  ASIO     [main] No TransportLayer configured during NetworkInterface startup
  2020-04-16T16:54:03.387+0100 I  CONTROL  [initandlisten] MongoDB starting : pid=76453 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=bogdanmac.mynet
  2020-04-16T16:54:03.387+0100 I  CONTROL  [initandlisten] db version v4.2.5
  2020-04-16T16:54:03.387+0100 I  CONTROL  [initandlisten] git version: 2261279b51ea13df08ae708ff278f0679c59dc32
  2020-04-16T16:54:03.387+0100 I  CONTROL  [initandlisten] allocator: system
  2020-04-16T16:54:03.387+0100 I  CONTROL  [initandlisten] modules: none
  2020-04-16T16:54:03.387+0100 I  CONTROL  [initandlisten] build environment:
  2020-04-16T16:54:03.387+0100 I  CONTROL  [initandlisten]     distarch: x86_64
  2020-04-16T16:54:03.387+0100 I  CONTROL  [initandlisten]     target_arch: x86_64
  2020-04-16T16:54:03.387+0100 I  CONTROL  [initandlisten] options: { config: "/usr/local/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/usr/local/var/mongodb" }, systemLog: { destination: "file", logAppend: true, path: "/usr/local/var/log/mongodb/mongo.log" } }
  2020-04-16T16:54:03.387+0100 E  NETWORK  [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock Permission denied
  2020-04-16T16:54:03.387+0100 F  -        [initandlisten] Fatal Assertion 40486 at src/mongo/transport/transport_layer_asio.cpp 684
  2020-04-16T16:54:03.387+0100 F  -        [initandlisten] 
  
  ***aborting after fassert() failure
  </code></pre>