I keep getting this error while trying to set up this skeleton application. I have no idea how to fix it sadly. Any input would be much appreciated. I'm just trying to get the darn thing up.
C:\Users\x\Desktop\mean-stripdown-master>node server
Express app started on port 3000
events.js:72
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
at null.<anonymous> (C:\Users\x\Desktop\mean-stripdown-master\node_modul
es\mongoose\node_modules\mongodb\lib\mongodb\connection\server.js:540:74)
at EventEmitter.emit (events.js:106:17)
at null.<anonymous> (C:\Users\x\Desktop\mean-stripdown-master\node_modul
es\mongoose\node_modules\mongodb\lib\mongodb\connection\connection_pool.js:140:1
5)
at EventEmitter.emit (events.js:98:17)
at Socket.<anonymous> (C:\Users\x\Desktop\mean-stripdown-master\node_mod
ules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection.js:478:10)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:415:13)
Related
I have developed NodeJS application and using OrientDB database in our project. Everything works fine until we left the application idle for sometime. We are facing time out error in OrientDB.
Please find the error below:
Unhandled rejection OrientDB.ConnectionError [2]: read ETIMEDOUT
at Connection.handleSocketError (/home/myuser/sample_app/node_modules/orientjs/lib/transport/binary/connection.js:352:9)
at Socket.emit (events.js:315:20)
at Socket.EventEmitter.emit (domain.js:485:12)
at emitErrorNT (internal/streams/destroy.js:100:8)
at emitErrorCloseNT (internal/streams/destroy.js:68:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Please advice
I attempted to follow the guide here https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql-postgres
to integrate my app with the Cloud SQL postgres instance. However I keep getting an error:
Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Application startup
error:
testpostgres#1.0.0 start /app node app.js
Unhandled rejection SequelizeConnectionError: connect ENOENT
/cloudsql/test-postgress:us-central1:testpostgress/.s.PGSQL.5432 at
connection.connect.err
(/app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:128:24) at Connection.connectingErrorHandler
(/app/node_modules/pg/lib/client.js:123:14) at emitOne
(events.js:116:13) at Connection.emit (events.js:211:7) at
Socket.reportStreamError
(/app/node_modules/pg/lib/connection.js:71:10) at emitOne
(events.js:116:13) at Socket.emit (events.js:211:7) at emitErrorNT
(internal/streams/destroy.js:64:8) at _combinedTickCallback
(internal/process/next_tick.js:138:11) at process._tickCallback
(internal/process/next_tick.js:180:9)
It must be a problem with my configuration, but I have tried everything I can think of. You can see or clone my project here:
https://github.com/fractalfrenzy/GCS_postgres_test
I know nothing of Node.js, but have a long experience with Java/Python/Go runtime.
Have you opened your CloudSQL instance for connection?
Try this: Configuring IP Connectivity
I am trying to connect my nodejs with mongoDB but it is not working fine as the following result below.
**
(node:11776) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your o
wn promise library instead: http://mongoosejs.com/docs/promises.html
{ MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0
.1:27017]
at Pool.<anonymous> (D:\KIT\YEAR II\Project\Nodejs\Vidjot\node_modules\mongodb-core\lib\topologies\server.js:336:3
5)
at emitOne (events.js:116:13)
at Pool.emit (events.js:211:7)
at Connection.<anonymous> (D:\KIT\YEAR II\Project\Nodejs\Vidjot\node_modules\mongodb-core\lib\connection\pool.js:2
80:12)
at Object.onceWrapper (events.js:317:30)
at emitTwo (events.js:126:13)
at Connection.emit (events.js:214:7)
at Socket.<anonymous> (D:\KIT\YEAR II\Project\Nodejs\Vidjot\node_modules\mongodb-core\lib\connection\connection.js
:187:49)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
name: 'MongoError',
message: 'failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1
:27017]' }
**
Here is my source code
Make sure your mongo server is running # localhost:27017 and you have directories created to store data.
start using this command:
>mongod --port 27017 --dbpath c:\data\db
I was running a nodejs api as a pod on a google compute engine managed by kubernetes. The API was connecting to database well but then it failed suddenly showing this error:
listening to http server on 0.0.0.0:8080...
events.js:160
throw er; // Unhandled 'error' event
^
MongoError: failed to connect to server [mongo:27017] on first connect [MongoError: getaddrinfo ENOTFOUND mongo mongo:27017]
at Pool.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/topologies/server.js:328:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:274:12)
at Connection.g (events.js:292:16)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:191:7)
at Socket.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/connection/connection.js:177:49)
at Socket.g (events.js:292:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at connectErrorNT (net.js:1021:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
I tried to restart the prods, to delete and re-create containers but no success?
this is how I connect to database:
mongoose.connect(process.env.MONGO_DEV_URL || process.env.MONGODB_URI || 'mongodb://mongo:27017:yaxiDb/yaxiDb', { useMongoClient: true });
How can I debug this, where could be the problem?
I just found the solution, the order of creating services matters. I've deleted all services that use that database and re-create them:
kubectl delete -f containers/backend/
kubectl create -f containers/backend/
I check the MongoDB service is in running and I can connect MongoDB unsing /bin/mongo.exe BUT I cannot connect to MongoDB server using nodejs driver.
My codes are working on Windows 10. The error messages are below.
C:\Documents and Settings\Administrator\Desktop\src\server>node server.js
Listening on port 80
C:\Documents and Settings\Administrator\Desktop\src\server\node_modules\mongodb\
lib\mongo_client.js:225
throw err
^
MongoError: failed to connect to server [127.0.0.1:27017] on first connect
at null.<anonymous> (C:\Documents and Settings\Administrator\Desktop\src\ser
ver\node_modules\mongodb\node_modules\mongodb-core\lib\topologies\server.js:313:
35)
at emitOne (events.js:77:13)
at emit (events.js:169:7)
at null.<anonymous> (C:\Documents and Settings\Administrator\Desktop\src\ser
ver\node_modules\mongodb\node_modules\mongodb-core\lib\connection\pool.js:260:12
)
at g (events.js:260:16)
at emitTwo (events.js:87:13)
at emit (events.js:172:7)
at Socket.<anonymous> (C:\Documents and Settings\Administrator\Desktop\src\s
erver\node_modules\mongodb\node_modules\mongodb-core\lib\connection\connection.j
s:162:49)
at Socket.g (events.js:260:16)
at emitOne (events.js:77:13)
Use lower version of mongodb driver.
In this case, I use 1.4.