0

When I am typing npm start in the bash to run my app locally, I get this result:

Listening on http://localhost:7200 Error connecting to mongo { MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017] at Pool. (C:\Users\Lope\Desktop\trainingCampus\week6\BERcycle\node_modules\mongodb-core\lib\topologies\server.js:431:11) at Pool.emit (events.js:198:13) at connect (C:\Users\Lope\Desktop\trainingCampus\week6\BERcycle\node_modules\mongodb-core\lib\connection\pool.js:557:14) at makeConnection (C:\Users\Lope\Desktop\trainingCampus\week6\BERcycle\node_modules\mongodb-core\lib\connection\connect.js:39:11) at callback (C:\Users\Lope\Desktop\trainingCampus\week6\BERcycle\node_modules\mongodb-core\lib\connection\connect.js:261:5) at Socket.err (C:\Users\Lope\Desktop\trainingCampus\week6\BERcycle\node_modules\mongodb-core\lib\connection\connect.js:286:7) at Object.onceWrapper (events.js:286:20) at Socket.emit (events.js:198:13) at emitErrorNT (internal/streams/destroy.js:91:8) at emitErrorAndCloseNT (internal/streams/destroy.js:59:3) at process._tickCallback (internal/process/next_tick.js:63:19) name: 'MongoNetworkError', errorLabels: [ 'TransientTransactionError' ], [Symbol(mongoErrorContextSymbol)]: {} }

How can I solve this?

Hasta Dhana
  • 4,699
  • 7
  • 17
  • 26

4 Answers4

0

Try out the following code:

 sudo rm -rf /tmp/mongodb-27017.sock
 sudo service mongod start


 ls -lsah /tmp/mongodb-27017.sock
0 srwx------ 1 mongodb mongodb 0 Aug 24 04:01 /tmp/mongodb-27017.sock 
Pang
  • 9,564
  • 146
  • 81
  • 122
Pushprajsinh Chudasama
  • 7,772
  • 4
  • 20
  • 43
  • Unfortunately, no. I get the same result. But cannot connect to Mongo. Mongo does not react when I click the connect button. – Tuba Kasap Aug 30 '19 at 06:35
  • this is the result again: – Tuba Kasap Aug 30 '19 at 06:35
  • Error connecting to mongo { MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017] at Pool. (C:\Users\Lope\Desktop\trainingCampus\week6\BERcycle\node_modules\mongodb-core\lib\topologies\server.js:431:11) at Pool.emit (events.js:198:13) at connect (C:\Users\Lope\Desktop\trainingCampus\week6\BERcycle\node_modules\mongodb-core\lib\connection\pool.js:557:14) at makeConnection (C:\Users\Lope\Desktop\trainingCampus\week6\BERcycle\node_modules\mongodb-core\lib\connection\connect.js:39 – Tuba Kasap Aug 30 '19 at 06:36
  • Try my ypdated code @TubaKasap – Pushprajsinh Chudasama Aug 30 '19 at 06:40
  • I tried already – Tuba Kasap Aug 30 '19 at 10:32
  • See the following "https://stackoverflow.com/questions/50173080/mongonetworkerror-failed-to-connect-to-server-localhost27017-on-first-connec/50173162" . May it help you . @TubaKasap – Pushprajsinh Chudasama Aug 30 '19 at 10:38
0

A TransientTransactionError is a transactional error that is classified as temporary, and if retried it may be successful. Furthermore, a TransientTransactionError write conflict occurs prior to a commit when no write lock has been taken and the transaction (new data) is not reflected in the transaction snapshot (previous data). As a result, these errors are completely safe to retry until there is a successful commit

Please also try to add your current IP to whiteList following "main page > security section > network access > add IP" in MongoDB website

Dexter
  • 831
  • 8
  • 17
0

First, Check If you are able to connect with mongo locally,
Use this command

mongo

Now there will be two scenario.
1. mongo is not running locally on localhost:27017
2. If mongo is running locally then use below command
mongod

Above command will give you the exact error causing mongo to not start.
Do check this and then share further detail.

adeel
  • 321
  • 2
  • 8
0

Here's what I do and have everything up and running without issues. After downloading mongo from official site, unzip the contents, change the folder name to “mongodb”, and move it to your users home directory. From there, create a “mongodb-data” directory in your user directory to store the database data. You can start the server using the following command. Make sure to swap out “username” with the correct path to your users home directory. /Users/{username}/mongodb/bin/mongod --dbpath=/Users/{username}/mongodb-data

This is for Mac installation btw but should be similar to other OSs

Dimitrios Douras
  • 506
  • 4
  • 16