简体   繁体   English

获取502错误的网关:尝试在PCF平台中使用节点js连接mongodb时,注册端点无法处理请求

[英]Getting 502 Bad Gateway: Registered endpoint failed to handle the request when tried to connect mongodb using node js in PCF platform

I have mongodb in AWS EC2 instance . 我在AWS EC2实例中mongodb

I am trying to connec to mongodb instance from nodejs server using mongoClient . 我正在尝试使用mongoClient从nodejs服务器连接到mongodb实例。 My node application is deployed on PCF platform. 我的节点应用程序已部署在PCF平台上。

When i try to connect to mongodb 当我尝试连接到mongodb
it throws an error " 502 Bad Gateway : 它抛出错误“ 502 Bad Gateway

Registered endpoint failed to handle the request". My node application is working fine, one the connection with mongodb is causing the problem. 注册的端点无法处理该请求。”我的节点应用程序运行正常,与mongodb的连接之一导致了问题。

conn_str += req.params.dbname;
mongoClient.connect(conn_str, function(err, db) {
    if(err) {
        res.end(err);
    } else {
        res.end(db);
    }
});

Help much appreciated. 帮助非常感谢。

Ok. 好。 I had faced a similar issue while I was trying to connect to my mongo cluster which was deployed on Google Compute Engine. 当我尝试连接到部署在Google Compute Engine上的mongo群集时,我遇到了类似的问题。 The below checklist helped me resolve the issue 以下清单帮助我解决了问题

  1. Check if your firewall and make sure that the port 27017 is open for external requests 检查您的防火墙,并确保打开端口27017以接收外部请求
  2. Check if your MongoDB is up and running (just do a curl localhost:27017 from terminal) if it's running you should get the protocol error 检查您的MongoDB是否已启动并正在运行(只需从终端执行curl localhost:27017),如果它正在运行,则应收到协议错误
  3. Check if your MongoDB is configured to accept requests from applications that is outside it's network (if you're running on different VPC) -- By default, MongoDB doesn't allow external requests 检查您的MongoDB是否配置为接受来自其网络外部的应用程序的请求(如果您在其他VPC上运行)-默认情况下,MongoDB不允许外部请求

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 (Cloud Foundry, Node.js) 502 Bad Gateway:注册端点无法处理请求 - (Cloud Foundry, Node.js) 502 Bad Gateway: Registered endpoint failed to handle the request 验证密码时出现“ 502错误的网关:请求端点无法处理” - Getting “502 bad gateway: request endpoint unable to handle” while validating the password 在 node.js 的生产服务器上获取 502 Bad Gateway - Getting 502 Bad Gateway on the production server for node.js 在新域上将Let's Encrypt与Nginx和Node.js一起使用时出现502错误网关 - 502 Bad Gateway when using Let's Encrypt with Nginx and Node.js on new domain Nginx 502 错误的网关节点 JS - Nginx 502 Bad Gateway Node JS AWS API 网关与 Lambda HTTP GET 请求(Node.js)502 错误网关 - AWS API Gateway with Lambda HTTP GET Request (Node.js) 502 Bad Gateway 节点 JS AWS 无服务器 502 HTTP/1.1 502 错误网关 - Node JS AWS Serverless 502 HTTP/1.1 502 Bad Gateway Node.js/Express.js/consign(): 默认请求有效 ("/") 但 ("/tasks") 返回 502:Bad Gateway - Node.js/Express.js/consign(): default request works ("/") but ("/tasks") returns a 502:Bad Gateway Jenkins 服务在节点 js 构建期间完全停止,在 Ubuntu 上使用 nginx 设置获得 502 错误网关 - Jenkins service stops completely during a node js build, getting a 502 bad gateway with an nginx setup on Ubuntu 当我在节点应用程序中使用https localhost url时,使用ngrok获取502 Bad Gateway错误 - Getting 502 Bad Gateway error with ngrok when I use https localhost url in a Node App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM