Guest User

Untitled

a guest
Jan 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. events.js:141
  2. throw er; // Unhandled 'error' event
  3. MongoError: connection 0 to localhost:27017 timed out
  4. at Function.MongoError.create (/home/ubuntu/scripts/node_modules/mongodb-core/lib/error.js:29:11)
  5. at Socket.<anonymous> (/home/ubuntu/scripts/node_modules/mongodb-core/lib/connection/connection.js:184:20)
  6. at Socket.g (events.js:260:16)
  7. at emitNone (events.js:67:13)
  8. at Socket.emit (events.js:166:7)
  9. at Socket._onTimeout (net.js:318:8)
  10. at _runOnTimeout (timers.js:524:11)
  11. at _makeTimerTimeout (timers.js:515:3)
  12. at Timer.unrefTimeout (timers.js:584:5)
  13.  
  14. var mongoose = require('mongoose');
  15. var option = {
  16. server: {
  17. socketOptions: {
  18. keepAlive: 300000,
  19. connectTimeoutMS: 30000
  20. }
  21. },
  22. replset: {
  23. socketOptions: {
  24. keepAlive: 300000,
  25. connectTimeoutMS: 30000
  26. }
  27. }
  28. };
  29.  
  30. var mongoURI = process.env.MONGODB_URI;
  31. mongoose.connect(mongoURI, option).then(function(){
  32. //connected successfully
  33. }, function(err) {
  34. //err handle
  35. });
Add Comment
Please, Sign In to add comment