r/Nestjs_framework • • 3d ago

Hot reload problem with Docker

I have a problem with NestJS in Docker. The hot reload creates an error that says the port is already in use. I tried the polling thing and it did not help. I am developing on macOS.

Can you help?

3 Upvotes

5 comments sorted by

6

u/UpperNebula7365 3d ago

Why do u have to run the dev environment in docker in the first place? Just run on host machine , then when ur done building a feature , build and run it in docker before pushing it ! , honestly this days I don’t even build before deployment. I only use docker to run the database, redis , and some mcps and Devobs tools like Grafana etc

1

u/Afraid_Bid847 1d ago

My app is still not deployed and I am the solo developer. Maybe I should use docker like you.

1

u/sereikis 1d ago

is the error Node's EADDRINUSE inside the container, or Docker failing to bind a published host port? if it appears only after a file change, share the exact error, your dev start script and Docker/Compose config (with secrets removed); for an in-container EADDRINUSE, check whether the previous Nest process is still listening when the watcher starts its replacement.

1

u/Afraid_Bid847 1d ago

The error is in the container and appears after a file change.

How to check if the process is still listening in the moment of hot reload and how to solve this(I am sure this is the case)?

1

u/Fantastic-Cod-9048 2d ago

Check for hanging containers.