NodeJS only listens on localhost

I have developed a NestJS Server application. NestJs is a node server running with express written in TypeScript.

Now I want to deploy the application on my rapsberry pi. However, I'm only able to access the server from localhost. If I try to access from a different client no content is returned. (The "^C" in the picture is only the cancel sign ;D)

I already set the hostname to What else can I do?

# /src/main.ts 
import {NestFactory} from '@nestjs/core';
import {AppModule} from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await app.listen(3001, '');

See picture

1 answer

  • answered 2019-02-10 12:52 Darek Adamkiewicz

    You must open firewall port and service, see below (this works for CentOS box):

    #add port
    sudo firewall-cmd --add-port=3001/tcp  --permanent
    # add service
    sudo firewall-cmd --permanent --add-service=http
    # reload !!! IMPORTANT !!!
    sudo firewall-cmd --reload