šŸš€ LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
šŸŽ“ COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///

Untitled Lesson

⚔ Total XP: 0|šŸ’» backend XP: 0

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Select an unlocked node to view details root

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Common Pitfalls & Errors

The Error //

Forgetting -p and then wondering why localhost:3000 refuses the connection

# Wrong: no port published, browser can never reach it docker run my-node-app # Correct: maps host port 3000 to the container's port 3000 docker run -p 3000:3000 my-node-app

The Solution //

A container's network is isolated from the host by default — the Node server inside genuinely is listening on port 3000, but nothing on the host machine is forwarded to it. You must explicitly map a host port to the container's port with -p [hostPort]:[containerPort], and the container port must match the port your app.listen() call actually uses.

The Error //

Accumulating dozens of stopped containers because `docker run` was used instead of `docker run --rm` for one-off tests

# Leaves a stopped container behind after Ctrl+C docker run -p 3000:3000 my-node-app # Auto-removes itself on exit — ideal for quick tests docker run --rm -p 3000:3000 my-node-app

The Solution //

Every `docker run` (without -d and without stopping it) creates a new container instance that lingers in a stopped state after Ctrl+C, visible in `docker ps -a`, silently consuming disk space over weeks of development. For throwaway test runs, add --rm so the container is automatically deleted the moment it exits.

Continue Learning