Programing

오류에서 localhost를 해제하는 방법 : EADDRINUSE 듣기

crosscheck 2020. 7. 26. 12:26
반응형

오류에서 localhost를 해제하는 방법 : EADDRINUSE 듣기


Windows 7에서 nodejs로 작성된 서버를 테스트하고 있으며 명령 줄에서 테스터를 실행하려고하면 다음 오류가 발생합니다.

Error: listen EADDRINUSE
at errnoException (net.js:614:11)
at Array.0 (net.js:704:26)
at EventEmitter._tickCallback (node.js:192:40)

재부팅하지 않고 어떻게 해결할 수 있습니까?


서버를 바인딩하려는 주소가 사용 중임을 의미합니다. 다른 포트를 사용해 보거나 해당 포트를 사용하여 프로그램을 닫으십시오.


운영:

ps -ax | grep node

당신은 다음과 같은 것을 얻을 것입니다 :

60778 ??         0:00.62 /usr/local/bin/node abc.js

그런 다음 수행하십시오.

kill -9 60778

Linux에서 (최소한 우분투 파생 상품)

killall node

이 양식보다 쉽습니다.

ps | grep <something>
kill <somepid>

포트를 잡고있는 고아가있는 경우에도 작동하지 않습니다. 대신 다음을 수행하십시오.

netstat -punta | grep <port>

포트가 유지되면 다음과 같은 것을 볼 수 있습니다 :

tcp           0      0.0.0.0:<port>          0.0.0.*       LISTEN     <pid>/<parent>

이제 pid로 죽여라.

kill -9 <pid>

다음 명령은 실행중인 노드 프로세스 목록을 제공합니다.

ps | grep node

해당 포트를 비우려면 다음을 사용하여 프로세스를 중지하십시오.

kill <processId>

EADDRINUSE응용 프로그램에서 사용하려는 포트가 다른 프로세스에 의해 점유되어 있기 때문에 오류가 발생 합니다. 이 포트를 해제하려면 점유 프로세스를 종료해야합니다.

당신이에 있기 때문에 윈도우 , 명령 프롬프트를 사용하여 프로세스를 종료 할 수 있습니다 ( cmd). 를 사용하면 cmd차단 애플리케이션의 프로세스 ID (PID)를 발견 할 수 있습니다. 프로세스를 종료 / 종료하려면 PID가 필요합니다.

단계별 가이드는 다음과 같습니다.

  1. 지정된 포트에서 실행중인 모든 프로세스를 찾으십시오 (이 예에서 포트는 "3000"임).

    netstat -ano | ": 3000"찾기

  2. netstat명령은 지정된 포트에서 실행중인 모든 프로세스를 나열합니다. netstat결과 의 마지막 열 에서 PIDs를 볼 수 있습니다 (이 예에서 PID는 "8308"입니다). PID다음 명령을 실행하여 특정 대한 자세한 정보를 찾을 수 있습니다 .

    작업 목록 / fi "pid eq 8308"

  3. 프로세스를 종료하려면 다음 명령을 사용하여 프로세스를 종료 할 수 있습니다 PID(이 예에서는 PID는 "8308"임).

    taskkill / pid 8308 / f

스크린 샷

여기에 이미지 설명을 입력하십시오


오류가 발생하면 EADDRINUSE를 듣고

다음 쉘 명령을 실행하십시오.

netstat -a -o | grep 8080
taskkill /F /PID 6204

I greped for 8080, because I know my server is running on port 8080. (static tells me when I start it: 'serving "." at http://127.0.0.1:8080'.) You might have to search for a different port.


suppose your server is running on port 3000

lsof -i tcp:3000
    COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    node    11716 arun   11u  IPv6 159175      0t0  TCP *:3000 (LISTEN)

after that use kill -9 <pid>

in the above case sudo kill -9 11716


use below command to kill a process running at a certain port - 3000 in this example below

kill -9 $(lsof -t -i:3000)

One possible solution that worked for me was simply to close the window in browser where I had the corresponding "http://localhost:3000/" script running.


When you get an error

Error: listen EADDRINUSE

Open command prompt and type the following instructions:

netstat -a -o | grep 8080
taskkill /F /PID** <*ur Process ID no*>

after that restart phone gap interface.

If you want to know which process ID phonegap is using, open TASK MANAGER and look at the Column heading PID and find the PID no.


Check the Process ID

sudo lsof -i:8081

Than kill the particular Process

sudo kill -9 2925

여기에 이미지 설명을 입력하십시오


The aforementioned killall -9 node, suggested by Patrick works as expected and solves the problem but you may want to read the edit part of this very answer about why kill -9 may not be the best way to do it.

On top of that you might want to target a single process rather than blindly killing all active processes.

In that case, first get the process ID (PID) of the process running on that port (say 8888):

lsof -i tcp:8888

This will return something like:

COMMAND   PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
node     57385   You   11u  IPv6 0xac745b2749fd2be3      0t0  TCP *:ddi-tcp-1

(LISTEN) Then just do (ps - actually do not. Please keep reading below):

kill -9 57385

you can change your port in app.js or in ur project configuration file.

default('port', 80)

and to see if port 80 is already in use you can do

netstat -antp |grep 80

netstat -antp |grep node

you might wanna see if node process is already running or not.

ps -ef |grep node

and if you find its already running, you can kill it using

killall node


This works on Mac:

Step 1.

sudo lsof -i tcp:3000 (or whatever port you want to kill)

Above command will give you the Process Id(s) currently holding the port.

Step 2.

Kill -9 <pid>

I created 2 servers, listening on same port 8081, running from same code, while learning

1st server creation shud have worked 2nd server creation failed with EADDRINUSE

node.js callback delays might be reason behind neither worked, or 2nd server creation had exception, and program exited, so 1st server is also closed

2 server issue hint, I got from: How to fix Error: listen EADDRINUSE while using nodejs?


Error: listen EADDRINUSE to solve it in Ubuntu run in terminal netstat -nptl and after this kill -9 {process-number} this command is to kill node process and now you can try to run again node server.js command

Ex

listen EADDRINUSE :::8080

netstat -nptl

tcp6 0 0 :::9000 :::* LISTEN 9660/java
tcp6 0 0 :::5800 :::* LISTEN -
tcp6 0 0 :::5900 :::* LISTEN -
tcp6 0 0 :::8080 :::* LISTEN 10401/node
tcp6 0 0 :::20080 :::* LISTEN 9660/java
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 :::10137 :::* LISTEN 9660/java

kill -9 10401


I have node red installed on my Mac and my Raspberry Pi. Had the exact same problem and doing 'killall' didn't help. Once I shut down the Raspberry Pi and restarted my computer it worked fine.


It may be possible that you have tried to run the npm start command in two different tabs .you cant run npm start when it is already running in some tab.check it once .


To anyone who has tried all of the above, but still can't find the rouge process, try them all again but make sure you include "sudo" in front of the commands.


If you like UI more, find the process Node.js in windows task manager and kill it.


ps -ef |grep node find app.js , kill pid of app.js


simply kill the node as pkill -9 node in terminal of ubantu than start node


To kill node server first run this command in your terminal :

  1. top
  2. open another window then copy the server id from the previous window: PID number -9 kill so now you killed your node server try again to run your app.

In my case, Machine restart solved the issue.


netstat -ano | grep "portnumber"해당 프로세스의 포트 번호 / PID를 나열하기 위해 명령 사용했습니다 . 그런 다음 taskkill -f //pid 111111프로세스를 종료 하는 사용할 수 있습니다 . 마지막 값은 첫 번째 명령에서 찾은 pid입니다.

때때로 문제가 발생하는 한 가지 문제는 프로세스를 종료 한 후에도 노드가 다시 생성되는 것이므로 이전 작업 관리자를 사용하여 수동으로 노드 프로세스를 종료해야합니다.


터미널에서 다음 명령을 사용하여 포트를 강제 종료해야합니다.

$ sudo killall -9 nodejs

창에서 다음 명령을 실행하십시오 :

taskkill /F /PID 1952

참고 URL : https://stackoverflow.com/questions/8553957/how-to-release-localhost-from-error-listen-eaddrinuse

반응형