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

After stoping Ctrl+C, I got address already in use when restart #333

Open
maelfosso opened this issue Feb 1, 2023 · 1 comment
Open

Comments

@maelfosso
Copy link

Issue description

To start my project, I ran yarn start which executes ts-node-dev src/index.ts
Every time I stop the project Ctrl+C, when I run it back again, I mean yarn start I have this error

$ yarn start
yarn run v1.22.19
$ ts-node-dev --respawn --transpile-only --tree-kill src/index.ts
[INFO] 01:57:37 ts-node-dev ver. 2.0.0 (using ts-node ver. 10.9.1, typescript ver. 4.9.4)
Starting ....
connected to localhost:4222
Error: listen EADDRINUSE: address already in use :::4000
    at Server.setupListenHandle [as _listen2] (node:net:1330:16)
    at listenInCluster (node:net:1378:12)
    at Server.listen (node:net:1465:7)
    at /Users/maelfosso/Documents/Projects/StockInos/rt/src/index.ts:29:10
    at Generator.next (<anonymous>)
    at fulfilled (/Users/maelfosso/Documents/Projects/StockInos/rt/src/index.ts:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
[ERROR] 01:57:37 Error: listen EADDRINUSE: address already in use :::4000
^C

Context

OS version (is it docker or host?), ts-node-dev version
MacOs Venture 13.0.1
ts-node-dev ver. 2.0.0 (using ts-node ver. 10.9.1, typescript ver. 4.9.4)

Did you try to run with ts-node?
No

Did you try to run with --files option enabled?
yes

Did you try to run with --debug option enabled?
yes

Do you have a repro example (git repo) with simple steps to reproduce your problem?
No

@aarhusgregersen
Copy link

Heya!

Bit late to the party, but this could very well be because the process didn't shut down properly.
If you are on Mac/Linux you can run the command ps aux | grep '<project-folder-name>' in your case it seems the folder name for the project is "StockInos" so you could do ps aux | grep 'StockInos'.

This will give you a list of processes running, with that folder name in the execution path, which usually matches the process that ts-node-dev is running.

An example from my pc:

❯ ps aux | grep 'backend'
redacted           60833   0,0  0,0 408636096   1456 s001  S+   10:23am   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox backend
redacted           60748   0,0  0,2 410851184  39232 s000  S+   10:19am   0:12.39 node /Users/redacted/code/redacted/backend/node_modules/.bin/ts-node-dev app.ts --watch

You will want to look for the number in the second column, just next to your username. You can see in my case it is 60748 .

All you have to do is then run kill -9 60478 and you should be able to start the server again :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants