A port number identifies a network endpoint where an application or service accepts traffic. Changing the port changes the URL used to reach a locally running application. section 2.2.2 section 5.1.2
Web applications commonly choose a default port but can read one from an environment variable or command-line option. Express.js defaults to 3000, while FastAPI can run through Uvicorn on a specified port. section 2.2.2 section 2.1.2
Containerized applications add a second port to the configuration:
- The container port is the port the application expects internally. section 5.1.2
- The local port is the host-side port used in a browser or other client. section 5.1.2
- Docker maps them with -p <localPort>:<containerPort>; for example, localhost:8080 reaches NGINX on container port 80. section 5.1.2
Moving an Express.js server
Run the default server with node main.js and visit http://127.0.0.1:3000. Stop it, then run PORT=3011 node main.js on macOS or Linux, or set PORT=3011 && node main.js on Windows. The server is now available at port 3011; the old port no longer responds. section 2.2.2
Listing 2.20 Running the Express.js web server on a new port
# macOs or Linux PORT=3011 node main.js # Windows set PORT=3011 && node main.js
Compare the macOS/Linux and Windows commands for starting Express.js on port 3011. section 2.2.2






