在连接mongodb时出现以下错误提示信息

events.js:
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:]
at null.<anonymous> (E:\64bit\WebStorm\untitled\node_modules\session-mongoose\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\server.js::)
at EventEmitter.emit (events.js::)
at null.<anonymous> (E:\64bit\WebStorm\untitled\node_modules\session-mongoose\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection_pool.js::)
at EventEmitter.emit (events.js::)
at Socket.<anonymous> (E:\64bit\WebStorm\untitled\node_modules\session-mongoose\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection.js::)
at Socket.EventEmitter.emit (events.js::)
at net.js::
at process._tickCallback (node.js::)

  出现以上错误是因为数据库mongodb没有运行

解决方案:

  1、下载:上http://www.mongodb.org/downloads,下载对应的Mongodb版本。

  2、启动:为了更好的规划,我们启动之前可以选建立一个db文件(随便在哪建都行,我的建在e:\db),用来存放mongodb数据库。然后启动cmd,进入你下载的mongose解压的路径的bin文件,例如我的为E:\64bit\WebStorm\mongodb2.4.9\bin>,然后输入mongod --dbpath=E:\db,这时启动了,如下图所示:

  

  3、测试是否运行:在浏览器中输入http://localhost:28017/,注意是28017,如果得到下图所示,那么说明成功了,别关掉,然后你就可以连接mongodb了

  

      

Nodejs学习之mongodb Error: failed to connect to [localhost:27017]的更多相关文章

  1. phpmailer的SMTP ERROR: Failed to connect to server: 10

    请问,我在win7上学习使用phpmailer时,出现这种错误怎么处理啊? SMTP ERROR: Failed to connect to server: (0) SMTP connect() fa ...

  2. 使用phpmailer插件发邮件失败提示:SMTP -> ERROR: Failed to connect to server: Connection timed out (110) smtp connect() failed;

    一个邮件发送问题,整整弄了我一周时间,起因是这样的,之前弄的一个网站,需要在邮箱里面认证之后才可以注册成功.网站上线了差不多一年之后,客户突然跟我说,网站不能注册了,然后我就查看了一下代码. 发现报这 ...

  3. error: failed to connect to the hypervisor error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory 解决办法

    服务器版本:CentOS Linux release 7.4 Linux lb 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x8 ...

  4. linux下phpmailer发送邮件出现SMTP ERROR: Failed to connect to server: (0)错误

    转自:https://www.cnblogs.com/raincowl/p/8875647.html //Create a new PHPMailer instance $mail = new PHP ...

  5. Docker - Failed to connect to localhost port 4000: Connection refused

    转载.翻译自 https://stackoverflow.com/questions/44014698/docker-failed-to-connect-to-localhost-port-4000- ...

  6. 【MongoDB】 Failed to connect to 127.0.0.1:27017, reason: Connection refused

    由于项目需要,在一台虚拟机上安装了MongoDB,但是在启动的时候,出现如下错误: [root@localhost bin]# ./mongo MongoDB shell version v3.4.0 ...

  7. MongoDB error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js(转)

    rror: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js 一般这种情况就是:自己指定的数据库,所以不能.自动加 ...

  8. 腾讯云服务器SMTP ERROR: Failed to connect to server

    一般邮件发送失败是 1.配置的问题. 2.扩展问题socket/ssl 百度搜出来一般都是以上的解决办法, 但是我这次遇到的不是. 本地可以放到腾讯云服务器就不行了,扩展也都开了. 后来发现是安全组端 ...

  9. linux 下 用phpmailer类smtp发送邮件始终不成功,提示:ERROR: Failed to co

    https://zhidao.baidu.com/question/509191264.html?fr=iks&word=PHPMailerSMTP+connect()+failed& ...

随机推荐

  1. Django学习手册 - 登录装饰器

    # 装饰器定义 def auth(func): def inner(request,*args,**kwargs): v = request.COOKIES.get("user") ...

  2. python - class类 (五) 继承补充-子类继承父类属性/函数方法

    子类继承父类属性/函数方法: #方式一:(原生方式,不建议使用) class Dongwu(object): def __init__(self,name,sex,old): self.name = ...

  3. 攻打医院服务器的SamSam勒索木马分析

    攻打医院服务器的SamSam勒索木马分析 近日一款名为SamSam的勒索木马在国外爆发.该木马利用医院系统的服务器漏洞实施入侵,再进行加密勒索钱财.由于医院网络信息安全水平普遍薄弱,SamSam成功感 ...

  4. SpringBoot整合MyBatis(注解版)

    详情可以参考Mybatis官方文档 http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/ (1). ...

  5. 关于MySQL 8.0的几个重点【转】

    转自 关于MySQL .0的几个重点,都在这里 https://mp.weixin.qq.com/s/QUpk9uuS2JTli1GT6HuORA 一.关于MySQL Server的改进 1.1 re ...

  6. 工作中bug笔记

    1.报Cannot read property  indexOf of undefined 错误的时候!!!报这种错的时候,一般是因为indexOf前面检查的东西是不存在的!!!!!  2.使用< ...

  7. 研究slatstack时踩过的坑,注意点及解决方案

    运行问题 1.直接物理性移除minion或者更换minion原先连接的master,会导致先前的master始终无法ping通minion [root@localhost salt]# salt '* ...

  8. 巧用CASE WHEN 验证用户登录信息

    最近逛博客园的时候偶然看到一个很巧妙的SQL,巧妙利用CASE WHEN 实现一个简单的 SQL 同时验证用户帐号是否存在.密码是否正确.晓菜鸟之前的做法都是根据用户名和密码一起验证,如果验证失败直接 ...

  9. 53环境Jenkins新增工程配置

    1. 登录http://10.179.175.53:8080/环境. 2. 点击新建任务,输入任务名称,并在复制一个NOS的类似工程即可. 3. 在配置页面,修改源码地址: 4. 点击完成,执行构建, ...

  10. HTML表格的简单使用1

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...