[英]connect() failed (111: Connection refused) while connecting to upstream.(node / nestjs) amazon Elastic
Trying to deploy my first app (Back-end).尝试部署我的第一个应用程序(后端)。 But I meet an error of the type 502 Bad Gateway.
但是我遇到了 502 Bad Gateway 类型的错误。
2022/04/16 09:40:14 [error] 4853#4853: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.46.123, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8081/", host: "172.31.12.175"
2022/04/16 09:40:16 [error] 4853#4853: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.6.213, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8081/", host: "172.31.12.175"
This is my main.ts file:-这是我的 main.ts 文件:-
async function bootstrap() {
const PORT = process.env.PORT || 8081;
const app = await NestFactory.create(AppModule, { cors: true });
app.useGlobalPipes(new ValidationPipe());
const configService = app.get(ConfigService);
app.enableCors();
await app.listen(process.env.PORT || 8081, () => {
console.log(`⛱ Talent Zea Cloud listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});
}
bootstrap();
EB uses port 8080 by default for node.js, but you are using port 8081
. EB 默认为 node.js 使用端口 8080 ,但您使用的是端口
8081
。 So either change your port, or setup PORT
env variable in EB to 8081
.因此,要么更改您的端口,要么将 EB 中的
PORT
env 变量设置为8081
。 From docs:来自文档:
By default, Elastic Beanstalk configures the proxy to forward requests to your application on port 8080 .
默认情况下,Elastic Beanstalk 将代理配置为将请求转发到端口 8080 上的应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.