Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Error: Timeout (2000) waiting for 127.0.0.1:9229 to be free #48

Closed
cristicmf opened this issue Aug 18, 2017 · 76 comments
Closed

Error: Timeout (2000) waiting for 127.0.0.1:9229 to be free #48

cristicmf opened this issue Aug 18, 2017 · 76 comments

Comments

@cristicmf
Copy link

Error: Timeout (2000) waiting for 127.0.0.1:9229 to be free
I have the same question

@jkrems
Copy link
Collaborator

jkrems commented Aug 18, 2017

Hey - thanks for the report! This should generally only happen if either a) you're using an older version of node-inspect or something else is genuinely blocking the port. The latter would happen if you'd try to start 2 CLI debuggers on the same machine.

Can you share an example script & command that was used to generate the error?

@Peripona
Copy link

there could also be the possibility, you are running node debug and try to run node inspect on another terminal.

@Michelle0609
Copy link

Hi ,I got the same issue. Does any one know how to fix that?
The script is very simple:
var person={
name:'Michelle'
};
person.age=25;
person.name='Mike';
console.log(person);

Command: node inspect app.js

@jkrems
Copy link
Collaborator

jkrems commented Nov 8, 2017

@Michelle0609 The most likely issue is that something else is running on port 9229. You can try running it on a different port using the following command:

node --inspect-port=9228 debug app.js

Alternatively you can try finding the thing blocking port 9229 on your machine. If neither of those options gets you anywhere, can you share the OS and version of node you're using?

@Michelle0609
Copy link

Michelle0609 commented Nov 8, 2017 via email

@jkrems
Copy link
Collaborator

jkrems commented Nov 8, 2017

Thanks for the details!

Wonder if there are any important error cases we're ignoring while trying. I don't have Windows around right now but I might be able to try debugging it when I'm back in the office tomorrow.

@Michelle0609
Copy link

Michelle0609 commented Nov 8, 2017 via email

@gosuto-inzasheru
Copy link

I encountered this error and found out while trying to close my Terminal window that there was another instance of node running in it still. Probably did not close it properly and that's why the port was blocked.

@shawncasaus
Copy link

To anyone making it to this thread with this issue, make sure you are exiting out of inspect using ctrl^c, not ctrl^z. If you use ctrl^z the debugger is still blocking the port and the only way to fix it is to exit and reenter terminal.

@blinking-in-the-light
Copy link

@Michelle0609 I got a good laugh from your example because it was identical enough to mine to know we were doing the same tutorial! Cheers.

@4rch1m3d35
Copy link

i'm having this issue as well and only have one terminal up still has same error
Node.js:12.2.0
OS: Windows 10
on VSC

$ node inspect app.js
Timeout (2000) waiting for 127.0.0.1:9229 to be free

@kerryja
Copy link

kerryja commented May 17, 2019

Hey @4rch1m3d35 did you figure this out? I am having the same problem!

@4rch1m3d35
Copy link

@kerryja nope nothing yet

@AleArmengol
Copy link

I'm having the same problem, did anyone figure this out? I already tried changing the port, but the error message is the same.
Timeout (2000) waiting for 127.0.0.1:9229 to be free
No matter what port I'm typing

@jkrems
Copy link
Collaborator

jkrems commented May 25, 2019

I'm having the same problem, did anyone figure this out? I already tried changing the port, but the error message is the same.

@AleArmengol To clarify your comment: Do you mean the message literally keeps talking about 9229 or just that you keep seeing timeouts for the various ports? If the port in the error stays the same, can you share the command you are using to set different ports?

@4rch1m3d35
Copy link

this is the command to change ports
node --inspect=127.0.0.1:9230

@jkrems
Copy link
Collaborator

jkrems commented May 27, 2019

To clarify, the command to start the CLI debugger on a custom port is node inspect --port=9230 path/to/script.js.

When using node --inspect, the error above shouldn't appear since that's the program being debugged, it's not starting the CLI debugger (node-inspect).

@victorgutemberg
Copy link

same issue here.

Node v10.13.0
Windows 10

Tried running in VSC and then another attempt in PowerShell.
Tried changing the ports and for all of then, the same error message appears.

Timeout (2000) waiting for 127.0.0.1:12903 to be free
Timeout (2000) waiting for 127.0.0.1:25612 to be free
Timeout (2000) waiting for 127.0.0.1:5122 to be free

@jkrems
Copy link
Collaborator

jkrems commented May 30, 2019

@victorgutemberg When you say "tried running in VSC", do you mean its integrated terminal? Also, can you share the exact command you ran?

@jkrems
Copy link
Collaborator

jkrems commented May 30, 2019

I wonder if this is something specific to Windows since so far that seems to be a common thread. I don't have a Windows machine anymore to test that on, so if somebody could do some debugging, it would be much appreciated. :)

@AleArmengol
Copy link

I ran this commands
node inspect --port=9229 app.js
Timeout (2000) waiting for 127.0.0.1:9229 to be free

node inspect --port=9230 app.js
Timeout (2000) waiting for 127.0.0.1:9230 to be free

@victorgutemberg
Copy link

@jkrems yeah, I meant the integrated terminal. I've tried using the default cdm and PowerShell, same result on both.

And the command that I was running is the same as just mentioned by @AleArmengol.

@pjgorman
Copy link

pjgorman commented Jun 2, 2019

same problem (node v 12.3.1) on Windows 10 Pro, Build 18362:
node inspect myScript.js gets "Timeout (2000) waiting for 127.0.0.1:9229 to be free".
Reproduced on various ports (9228, 9227)
Also, not specific to the VSC terminal. Reproduced in windows cmd and in powershell

Seems to work fine on the Windows 7 machine

@juergba
Copy link

juergba commented Jun 6, 2019

Same problem on Windows 10 Home, Node v12.2.0,
happens with different ports.

@hessproject
Copy link

I am also having this issue on different ports in Windows 10, both in VSC integrated terminal and regular powershell

@boba1987
Copy link

boba1987 commented Jul 3, 2019

Had the same issue, the problem was that I was starting multiple instances of node app inside a docker container, so the first instance that starts occupies 127.0.0.1:9229 and other instances cannot get to the port, thus trowing the error. After I set docker to start a single node app instance, error was gone

@4rch1m3d35
Copy link

unfortunately i am not using docker and i am only starting one instance of the integrated terminal

@linqFR
Copy link

linqFR commented Jul 7, 2019

Same problem : Timeout (2000) waiting for 127.0.0.1:9229 to be free

Windows x64 18362.207
Node 12.6.0 AND 10.16

and i have checked used ip:port (netstat command) and no entry is using this port

@vikingdv
Copy link

@yilmazdurmaz
Thanks! I opened node.exe in a hex editor and changed delay in portIsFree from 2000 to 3000. That was enough. Your comment was very helpful.
Windows 10 x64
Node 10.16

@95rajasekar
Copy link

Anyone knows whats the difference between node inspect app.js & node --inspect app.js
I was trying the first one and was facing the same Timeout issue. When i tried the latter it worked fine.

@jkrems
Copy link
Collaborator

jkrems commented Nov 5, 2019

Anyone knows whats the difference between node inspect app.js & node --inspect app.js

Yeah, those two commands look more similar than they should. The difference is:

  • node --inspect: Run app.js but expose the remote debugging interface that things like vscode, Chrome devtools, Intellij, etc. can attach to. Otherwise app.js will run just like always and have full control over the terminal.
  • node inspect: Start the interactive CLI debugger that's bundled with node. It's an alternative for visual debuggers like vscode or Chrome devtools. The CLI debugger will then use node --inspect to start the script in a separate process and attaches to it.

The relationship between the two is more obvious in the more explicit flow that also supports remote debugging across machines:

# Start app.js with the inspect interface exposed, by default on port 9229:
node --inspect app.js
# In a separate terminal, start the inspect client against port 9229:
node inspect -p 9229

Now the CLI debugger (node inspect) is connected to the node process with the debug interface enabled (node --inspect). Hope that helps. :)

@95rajasekar
Copy link

Anyone knows whats the difference between node inspect app.js & node --inspect app.js

Yeah, those two commands look more similar than they should. The difference is:

  • node --inspect: Run app.js but expose the remote debugging interface that things like vscode, Chrome devtools, Intellij, etc. can attach to. Otherwise app.js will run just like always and have full control over the terminal.
  • node inspect: Start the interactive CLI debugger that's bundled with node. It's an alternative for visual debuggers like vscode or Chrome devtools. The CLI debugger will then use node --inspect to start the script in a separate process and attaches to it.

The relationship between the two is more obvious in the more explicit flow that also supports remote debugging across machines:

# Start app.js with the inspect interface exposed, by default on port 9229:
node --inspect app.js
# In a separate terminal, start the inspect client against port 9229:
node inspect -p 9229

Now the CLI debugger (node inspect) is connected to the node process with the debug interface enabled (node --inspect). Hope that helps. :)

Thanks! got the diff b/w the two 👍

@Haisum92
Copy link

Haisum92 commented Dec 6, 2019

guys this works. just type node --inspect-brk "your filename.js" for eg: mine is app.js so
node --inspect-brk app.js @ @ @ @yilmazdurmaz @kerryja

node: ../deps/uv/src/unix/core.c:117: uv_close: Assertion `!(((handle)->flags & (UV_CLOSING | UV_CLOSED)) != 0)' failed.
Aborted (core dumped)

@yilmazdurmaz
Copy link
Contributor

@jkrems is there a way you may put a summary at the end and then put this discussion on a hold? it is too long that people miss the important parts we talked about.

@Prottoy2938
Copy link

I have tried --inspect-brk app.js, it works,
But I can't debug in crome when using this method. I press the play button in crome inspect, and nothing happens in the even I had typed debugger in my code.

And after typing --inspect-brk app.js the timeout error is happening again. So have anyone solved this issue? How do I get out of this timeout error?

@teriyaki-89
Copy link

use --inspect-brk

you're magician

@mm41707
Copy link

mm41707 commented Jan 26, 2020

  • find a hex editor, open node.exe, search for portIsFree, currently 2 results comes up, one of them has timeout = 2000 nearby, replace it with a higher value, I suggest 9999.

Hey! Great job. I didn't even expect to find any plain text parameters inside win PE file. Great clean solution, without any 3rd party modules. That's what i was hoping to get. Cheers man!

@Ang3lExtreme
Copy link

@mikemaccana Today, I am in a bit of debugger/patcher mood, so here is 4th, but surely unsupported method. After this, node inspect works without timeout error.

  • find a hex editor, open node.exe, search for portIsFree, currently 2 results comes up, one of them has timeout = 2000 nearby, replace it with a higher value, I suggest 9999.

While doing that, you will notice that Node.js actually holds packages almost as is. If you look at the beginning of the file, you will see the "native" codes. Native codes are only read by machine logic (assembler). In contrast, packages are hold as their human readable form.

Actually I didn't expect this result. Anyone may apply this method on their free will, just should not expect support if something else gets broken.

you are a god!

@rathore-raj
Copy link

any Of This is not working

@ghost
Copy link

ghost commented Apr 12, 2020

try this:

node --inspect-brk app.js

it works fine with me.

@rajithaeyee
Copy link

rajithaeyee commented Apr 18, 2020

node --inspect-brk app.js solves the problem

@rathore-raj
Copy link

Thanks Now its Working😅

jkrems added a commit that referenced this issue Apr 20, 2020
"portIsFree" function's "timeout" parameter value increased to solve issues #48, #54 and #70
@dwkrueger2
Copy link

We need to move the
node --inspect-brk app.js to the top of this feed instead of the bottom.

@yilmazdurmaz
Copy link
Contributor

"--inspect" and "--inspect-brk" does things in slight different ways, and depending on what you need the second does the jobs.

we have a fix about the "timeout" for "--inspect" already committed&merged, so possibly the next node version change will include it. as for the fix, it is an increased value on the setTimeout function, 2000 to 9999, because the problem here is that Windows is somehow slow on taking the requested port, about 3-5 seconds, thus timeout was happening.

keep an eye on it and update your node installation when the fixed one comes out.

@jkrems
Copy link
Collaborator

jkrems commented May 17, 2020

Update: A change increasing the timeout has landed here and there's an open PR to pull it into node (nodejs/node#33447).

@chumaachike
Copy link

Error: Timeout (2000) waiting for 127.0.0.1:9229 to be free
I have the same question

try node --inspect-brk filename.js

@PassionateInCoding
Copy link

Still I am facing issue with debugging. Didn't worked for me. Using node version v12.18.0.
node --inspect-brk index.js
Debugger listening on ws://127.0.0.1:9229/93410f83-bdd1-488d-bcc9-595904b41697
For help, see: https://nodejs.org/en/docs/inspector

@vivekvking
Copy link

Go to your chrome browser and enter the url: chrome://inspect
then you will find something under remote target, then just click on the inspect option given over there and you are good to go.
If you donot find anything under remote targets then click upon configure option there and enter the ip that you got on the console that is 127.0.0.1:9229

@PassionateInCoding
Copy link

@vivekvking , i have updated chrome://inspect and added configuration - discover network targets as 127.0.0.1:9229. But the issue resists to
Error: Timeout (2000) waiting for 127.0.0.1:9229 to be free
then realized, under https://nodejs.org/en/docs/guides/debugging-getting-started/ for latest version we need to install independently [npm install -g node-inspect] and [node-inspect myscript.js] worked for me.

@sagartyagi121
Copy link

If you want to debug your code use node --inspect yourJs.js
not node inspect yourJS.js

@juniorbuba
Copy link

juniorbuba commented Aug 16, 2020

Tried everything and none worked but node --inspect app

@jochri3
Copy link

jochri3 commented Aug 16, 2020

@mikemaccana Today, I am in a bit of debugger/patcher mood, so here is 4th, but surely unsupported method. After this, node inspect works without timeout error.

  • find a hex editor, open node.exe, search for portIsFree, currently 2 results comes up, one of them has timeout = 2000 nearby, replace it with a higher value, I suggest 9999.

While doing that, you will notice that Node.js actually holds packages almost as is. If you look at the beginning of the file, you will see the "native" codes. Native codes are only read by machine logic (assembler). In contrast, packages are hold as their human readable form.

Actually I didn't expect this result. Anyone may apply this method on their free will, just should not expect support if something else gets broken.

You're great❤️❤️❤️

@jbrandona119
Copy link

Typed up a whole gosh darn thing and after reading the docs I got it working finally! After installing globally with "npm install -g node-inspect" and restarting the terminal, I was able to use "node-inspect fileName.js" and it successfully starts and keeps the debugger running in that terminal. I suggest trying that if you're still struggling. I did try "node inspect" and "node --inspect" but they didn't work. What a strange issue!

@yilmazdurmaz
Copy link
Contributor

Hey there all future newcomers to the topic (and some old still struggling).

TL:DR - we have many possible solutions. please try to read comments.

I wish comments were not this long and we had the habit of reading long things, impossible by our nature.

just know that, we know the problem and we have the solutions.

PROBLEM: newer version of windows is slow to assign debug port that takes about 3-5 seconds, but this debug utility had a predefined (working in the past) 2 seconds timeout. this is the only reason we have this issue.

SOLUTION: we already have the fix submitted to Node.JS codebase, and sometime in the future, depending on Node's own release schedule. until then there are many working solutions depending on your expectation, so please, please, please read these comments and try solutions.

thanks for patience

PS: the solution in above comment works now without any modification because we really have it fixed here. two post above works too because of the nature of the problem; we need a simple timeout increase.

PS: I really hope new readers will at least read the last post in the line, and keep this one as the last post.

@harikanani
Copy link

To clarify, the command to start the CLI debugger on a custom port is node inspect --port=9230 path/to/script.js.

When using node --inspect, the error above shouldn't appear since that's the program being debugged, it's not starting the CLI debugger (node-inspect).

I'm having

i'm having this issue as well and only have one terminal up still has same error
Node.js:12.2.0
OS: Windows 10
on VSC

$ node inspect app.js
Timeout (2000) waiting for 127.0.0.1:9229 to be free

Same Issue is there but this Command Works for Mine.

node --inspect=127.0.0.1:9230 app_name.js

Thanks

@yilmazdurmaz
Copy link
Contributor

Hi all

Latest Node v12.19.0 and v15.0.1 now has the fix in them (timeout set to 9999ms). Please update your installations when you are ready.

@jkrems , this #48 and #54 issues should be safe to be marked as solved.

@Trott Trott closed this as completed Jun 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests