0

I've create a NestJS server that looks like that:

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as fs from 'fs'
import * as https from 'https'
import * as express from 'express'
import * as http from 'http'
import { ExpressAdapter } from '@nestjs/platform-express';

async function bootstrap() {

    const httpsOptions={
      key:fs.readFileSync('./secrets/key.pem','utf8'),
      cert: fs.readFileSync('./secrets/server.crt', 'utf8')
    }
    const server = express()
    const app = await NestFactory.create(AppModule, new ExpressAdapter(server));
    app.enableCors();
    await app.init()

    http.createServer(server).listen(3000)
    https.createServer(httpsOptions, server).listen(443, 'EXTERNAL_IP')
  }


  bootstrap();

I`m using my external IP as my request host but getting the next error: Error: listen EADDRNOTAVAIL: address not available EXTERNAL_IP:443.

GuyH-Dev
  • 3
  • 1

1 Answers1

0

It seems that you should use your server's ip or 0.0.0.0 instead of EXTERNAL_IP, you can find this workaround in these posts(possible duplicate)

node.js server.listen on a specific IP address EADDRNOTAVAIL

NodeJS - Error: listen EADDRNOTAVAIL: address not available

roberto_h
  • 79
  • 2
  • If I will put the IP 0.0.0.0 it won't let send requests from the hosting on firebase to my server on Google Cloud since it's not on the same LAN network, is it? The Request I make from the FE: const handleDataSend = () => { Axios.post('http://MACHINE_IP:3000/taboola-changer/changedParams',changeParams).then( res => { console.log(res) } ) } – GuyH-Dev Aug 18 '20 at 07:22