When a NestJS application starts, it uses ConfigModule.forRoot() to load environment variables from a .env file. This process reads the file, parses key-value pairs, and sets them in the Node.js process.env object. Before loading, process.env is empty for these variables. After loading, variables like PORT and DB_HOST are accessible anywhere in the app via process.env.PORT or process.env.DB_HOST. These values configure the app's behavior, such as which port to listen on or database connection details. If a variable is missing in the .env file, accessing it returns undefined, so defaults or validation are recommended. This approach keeps configuration separate from code, making apps flexible and secure.