0

I created an api using NestJs and GraphQL, exposing a GraphQL server (Apollo) with a certain port. Everything works fine as long as I am using http://localhost:3001/graphql endpoint. As soon as I change to http://<ip-address>:3001/graphql the connection cannot be established.

I modified main.ts file to include the host adress as well, and I was expecting to be able to reach the endpoint withing the same machine, but in vain.

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.enableCors();
  await app.listen(3001, '0.0.0.0', async () => {
    console.log(` Server started at ${await app.getUrl()}`);
  });
}
bootstrap();

Dependencies:

    "@nestjs/graphql": "^10.2.0",
    "graphql": "^16.6.0",
    "@nestjs/apollo": "^10.2.0",
Progman
  • 16,827
  • 6
  • 33
  • 48
iiSam
  • 61
  • 5
  • Are you able to `ping `? – Eyal Feb 11 '23 at 17:50
  • Yes I am. And I also tried to access the Apollo Sandbox from the same machine the server is running in, and I got the same result. In addition to that I have tested this on 3 different machines (Running the server in the machine and trying to access the Apollo Sandbox on the same machine using the IP) – iiSam Feb 11 '23 at 19:44

0 Answers0