title: NestJS App won't use the .env or configService PORT. Always starts on port 3000 no matter what
body: <p>I have a barebones NestJS app where all I have done is add a <code>.env</code> file with <code>PORT=3001</code> as the content and then modified my <code>main.ts</code> according to the <a href="https://docs.nestjs.com/techniques/configuration#using-in-the-maints" rel="nofollow noreferrer">NestJS docs</a>:</p>
  <pre class="lang-js prettyprint-override"><code>import { ConfigService } from '@nestjs/config';
  import { NestFactory } from '@nestjs/core';
  import { AppModule } from './app.module';
  
  async function bootstrap() {
    const app = await NestFactory.create(AppModule, {bufferLogs: true});
    const configService = app.get(ConfigService);
    const PORT = configService.get('PORT');
    app.listen(PORT);
  }
  bootstrap();
  </code></pre>
  <p>My AppModule:</p>
  <pre class="lang-js prettyprint-override"><code>@Module({
    imports: [
      ConfigModule.forRoot({isGlobal: true}),
      UsersModule
    ],
    controllers: [AppController],
    providers: [AppService],
  })
  
  export class AppModule {}
  </code></pre>
  <p>When I run the app, it always runs on port 3000. It never runs on port 3001. What is going on???</p>