Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live reload: EADDRINUSE: address already in use #14017

Closed
ArnaudDenoyelle opened this issue Dec 25, 2022 · 8 comments · Fixed by #14023
Closed

Live reload: EADDRINUSE: address already in use #14017

ArnaudDenoyelle opened this issue Dec 25, 2022 · 8 comments · Fixed by #14023

Comments

@ArnaudDenoyelle
Copy link
Contributor

Current Behavior

Just after creating a new nest project via nx :
Trying to save a file results in a EADDRINUSE error instead of live-reload
This happens only if the project is created with Nx. I can't reproduce it in a pure Nest repo

Expected Behavior

When I save a file, the server should live-reload

Github Repo

https://github.com/ArnaudDenoyelle/nest-EADDRINUSE

Steps to Reproduce

  1. Create a project : npx create-nx-workspace@latest acme --preset=nest --appName=api --nxCloud=false
  2. Go to the project directory : cd acme
  3. Start the server : nx serve api
  4. Modify a file like in app.service.ts and save

Nx Report

code/acme [ nx report

 >  NX   Report complete - copy this into the issue template

   Node : 14.20.0
   OS   : linux x64
   npm  : 6.14.17
   
   nx : 15.4.1
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.4.1
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.4.1
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.4.1
   @nrwl/js : 15.4.1
   @nrwl/linter : 15.4.1
   @nrwl/nest : 15.4.1
   @nrwl/next : Not Found
   @nrwl/node : 15.4.1
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/webpack : 15.4.1
   @nrwl/workspace : 15.4.1
   @nrwl/vite : Not Found
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

Failure Logs

nx serve api

> nx run api:serve

chunk (runtime: main) main.js (main) 2.78 KiB [entry] [rendered]
webpack compiled successfully (c16c5b6c32515b78)
Debugger listening on ws://localhost:9229/367b9385-0682-4385-9892-ac191eca53af
For help, see: https://nodejs.org/en/docs/inspector
Type-checking in progress...
[Nest] 43076  - 12/25/2022, 4:32:45 PM     LOG [NestFactory] Starting Nest application...
[Nest] 43076  - 12/25/2022, 4:32:45 PM     LOG [InstanceLoader] AppModule dependencies initialized +21ms
[Nest] 43076  - 12/25/2022, 4:32:45 PM     LOG [RoutesResolver] AppController {/api}: +4ms
[Nest] 43076  - 12/25/2022, 4:32:45 PM     LOG [RouterExplorer] Mapped {/api, GET} route +2ms
[Nest] 43076  - 12/25/2022, 4:32:45 PM     LOG [NestApplication] Nest application successfully started +2ms
[Nest] 43076  - 12/25/2022, 4:32:45 PM     LOG 🚀 Application is running on: http://localhost:3333/api
No errors found.
chunk (runtime: main) main.js (main) 2.78 KiB [entry] [rendered]
webpack compiled successfully (f206a56adc60ef30)
Starting inspector on localhost:9229 failed: address already in use
No errors found.
[Nest] 43162  - 12/25/2022, 4:32:59 PM     LOG [NestFactory] Starting Nest application...
[Nest] 43162  - 12/25/2022, 4:32:59 PM     LOG [InstanceLoader] AppModule dependencies initialized +20ms
[Nest] 43162  - 12/25/2022, 4:32:59 PM     LOG [RoutesResolver] AppController {/api}: +4ms
[Nest] 43162  - 12/25/2022, 4:32:59 PM     LOG [RouterExplorer] Mapped {/api, GET} route +2ms
[Nest] 43162  - 12/25/2022, 4:32:59 PM     LOG [NestApplication] Nest application successfully started +1ms
[Nest] 43162  - 12/25/2022, 4:32:59 PM   ERROR [NestApplication] Error: listen EADDRINUSE: address already in use :::3333 +2ms
(node:43162) UnhandledPromiseRejectionWarning: Error: listen EADDRINUSE: address already in use :::3333
    at Server.setupListenHandle [as _listen2] (net.js:1331:16)
    at listenInCluster (net.js:1379:12)
    at Server.listen (net.js:1465:7)
    at ExpressAdapter.listen (/home/arnaud/code/acme/node_modules/@nestjs/platform-express/adapters/express-adapter.js:78:32)
    at /home/arnaud/code/acme/node_modules/@nestjs/core/nest-application.js:167:46
    at new Promise (<anonymous>)
    at NestApplication.listen (/home/arnaud/code/acme/node_modules/@nestjs/core/nest-application.js:156:16)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:43162) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:43162) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Additional Information

Can be fixed by downgrading @nrwl/* dependencies to 15.3.3, in particular @nrwl/nest and @nrwl/node alone

@sahilpurav
Copy link
Contributor

sahilpurav commented Dec 26, 2022

I'm facing the same problem with new installation. It is not just happening with nest, I even tried to install express and the issue exist even for express framework.

@AgentEnder - I forked this repository and reverted #13813, it solved the problem so looks like the problem is 2 weeks old. I have got the resolution, let me raise a PR in couple of hours.

@firxworx
Copy link

Confirmed in 15.4.1

@beeman
Copy link
Contributor

beeman commented Dec 27, 2022

Also seeing this issue, it's pretty inconvenient.

I tested #14023 locally and that fixes it, let's hope it ships fast!

@hallowatcher
Copy link

hallowatcher commented Dec 27, 2022

Same issue here on every save, I have to restart the whole process which is very inconvenient.

Nx 15.4.1
@nestjs/core 9.2.1

image

@kenatwex
Copy link

kenatwex commented Jan 2, 2023

seeing this now on

nx report

 >  NX   Report complete - copy this into the issue template

   Node : 16.17.0
   OS   : darwin arm64
   yarn : 1.22.18
   
   nx : 15.4.2
   @nrwl/angular : 15.4.2
   @nrwl/cypress : 15.4.2
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.4.2
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.4.2
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.4.2
   @nrwl/js : 15.4.2
   @nrwl/linter : 15.4.2
   @nrwl/nest : 15.4.2
   @nrwl/next : Not Found
   @nrwl/node : 15.4.2
   @nrwl/nx-cloud : 15.0.2
   @nrwl/nx-plugin : 15.4.2
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.4.2
   @nrwl/schematics : 9.0.0-beta.3
   @nrwl/storybook : 15.4.2
   @nrwl/web : 15.4.2
   @nrwl/webpack : 15.4.2
   @nrwl/workspace : 15.4.2
   @nrwl/vite : 15.4.2
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
   	 @fortawesome/angular-fontawesome: 0.10.2
   	 @ngneat/transloco: 4.2.1
   	 @ngrx/component: 15.0.0
   	 @ngrx/component-store: 15.0.0
   	 @ngrx/effects: 15.0.0
   	 @ngrx/entity: 15.0.0
   	 @ngrx/router-store: 15.0.0
   	 @ngrx/store: 15.0.0
   	 @ngrx/store-devtools: 15.1.0
   	 apollo-angular: 3.0.1
   	 @buildmotion/angular: 13.0.1
   	 @ngrx/schematics: 15.1.0
   	 @storybook/angular: 6.5.15

@zhumeisongsong
Copy link

zhumeisongsong commented Jan 4, 2023

Faced the same issue when updated to 15.4.1 on every save.
Updated to 15.4.4 fixed it!

@pkyriakis
Copy link

Had the same issue, upgrating to the latest nx version fixed it!

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants