【问题标题】:Error occured while trying to proxy to: localhost:3000/api/graphql尝试代理时出错:localhost:3000/api/graphql
【发布时间】:2018-11-26 16:58:00
【问题描述】:

我已经启动 Node 服务器和 Mongod 并尝试运行示例程序。

命令提示符的输出:

mongod 命令提示符:

2018-06-17T23:38:19.464+0530 I FTDC     [initandlisten] Initializing full-time diagnostic 
data capture with directory 'C:/data/db/diagnostic.data'
2018-06-17T23:38:19.466+0530 I NETWORK  [initandlisten] waiting for 
connections on port 27017

mongo 命令提示符:

MongoDB shell 版本 v3.6.5

connecting to: mongodb://127.0.0.1:27017

我可以通过从命令提示符启动 mongo 在 mongo shell 中运行命令。 但是示例程序抛出异常。

http://localhost:3000/api/graphql

[0] [HPM] Error occurred while trying to proxy request /api/graphql from 
localhost:3000 to http://localhost:4040 (ECONNREFUSED) 
(https://nodejs.org/api/errors.html#errors_common_system_errors)

我不确定 4040 端口上没有其他进程正在运行。

让我知道如何解决此问题。

更新步骤顺序:

 install npm
 install mongodb
 $ git clone https://github.com/linnovate/mean.git
 $ cd mean
 $ npm install && npm start

 npm start will open default home page :  http://localhost:3000/
 On home page, click on GraphQL browser

【问题讨论】:

  • 您只发布了错误...请发布一些代码...您尝试在浏览器上粘贴localhost:4040/graphql 吗?它将显示连接是否建立
  • 这是来自 Node.js 的示例代码。默认主页(localhost:3000)浏览器中有一个链接GraphQL,它调用localhost:3000/api/graphql
  • 这个问题你解决了吗?

标签: node.js mongodb graphql


【解决方案1】:

您可以尝试将 localhost 替换为 [::1]。

http://[::1]:3000

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-16
    • 1970-01-01
    • 2021-09-28
    • 2015-04-10
    • 1970-01-01
    • 2019-07-07
    • 2014-04-23
    • 2018-10-28
    相关资源
    最近更新 更多