Process cannot be found - sockets

I'm currently working on a socket application and it appears that my code doesn't end the connection between the sockets and causes an error: bind failed with error: 10048.
I then wanted to shut down the process associated to this link using the 'taskkill /F /PID ....' command with the PID I found but the process cannot be found. Did I do something wrong here?
Here are the terminal commmands I used:
PS C:\Users\user> netstat -ano | findstr 8888
TCP 127.0.0.1:8888 0.0.0.0:0 LISTENING 11112
PS C:\Users\user> taskkill /F /PID 11112
Erreur : le processus "11112" est introuvable. **the process cannot be found**
It is also impossible to locate the process in the task manager.

Error 10048 is WSAEADDRINUSE, meaning the IP/port you are trying to bind to is still in use. Even though you shutdown a previous process that was using the IP/port, the OS itself is likely still holding the IP/port open and hasn't released it for reuse yet. By default, the OS internally holds onto a closed IP/port for an extra period of time to ensure any pending data for that IP/port gets flushed from the network. To work around that, you can enable the SO_REUSEADDR option on your listening sockets before binding them. Or, you can turn off a socket's SO_LINGER option before closing it.

Related

How to list currently running servers that are listening to localhost ports in vscode

I am using VS Code for development. After running the server as usually using npm start command (which was set up to run nodemon and the main 'app' file) I closed the terminal.
I thought that when terminal is shut down nodemon get shut down along with the terminal. Evidently this is not so as when I attempt to run npm start in the new terminal it throws an error that the port I set up my server to listen to is already in use.
Is it possible to see what servers are running currently and which ports they are listening to?
If there is no such command to list the currently running servers is there any way to shut down the running servers on the local machine without shutting down the laptop I am working on?
By the way everything mentioned above is being done on local machine and no remote server is used. Thank you in advance.
If you are on a Linux box you can run this to get the PID of any process running on that port:
Linux:
netstat -tnlp | grep {{PORT}}
This will likely find multiple lines since the number of the {{PORT}} value might show up in a PID, IP address, etc., so look through the list to find what you're looking for. The PID and process name will show up on the far right column of the result.
Example for Linux:
# netstat -tnlp | grep 443
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 14384/nginx: master
The column on the right (14384/nginx: master) is the PID of that process, and the process name. Once you have the PID you could do a kill {{PID}} to kill that process.
The Mac version of netstat is different, and doesn't display the PID (at least not that I can tell), and I'm not sure if there's a way to do the same thing on a Windows box.

Could not start Appium server. It's showing [Error Starting appium server: listen EADDRINUSE 0.0.0.0:4723]

I am using Appium version V1.15.0 and have already start the server successfully with the default Host: 0.0.0.0 and Port: 4723
But now when i try to start the server it shows me this error "Error Starting Appium server: listen EADDRINUSE 0.0.0.0:4723"
I have tried to solve this issue by changing the port but could not find any solution.
Suggest me if you guys have any better solution.
I have found the solution. After restarting my computer, i could successfully run the Appium server.
If anyone face the same problem. Please follow below steps:
1. Check if the port is listening to any other services.
Open command prompt: Type netstat -a -b
Either kill that service or try with different port.
If both not working then restart your machine.
This way i have solved this problem.
If EADDRINUSE, Address already in use is the issue,
do
ps aux | grep node
to get the process ids.
Then:
kill -9 PID
Doing the -9 on kill sends a SIGKILL.
That because port 4723 has been used.
We gonna find which process using it
sudo lsof -i :4723
input your Mac user password, press Enter and the result will similar to
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
AppX 68286 huyck 65u IPv4 0x31233f2022a17f56 0t0 TCP *:4723 (LISTEN)
that mean AppX with PID 68286 is using this port
And we are gonna kill it (replace 68286 with your PID)
sudo kill -9 68286
Another easier way, restart the machine could solve this problem
Hope this helps!
The following solution on windows worked for me
C:\Users\username> taskkill /F /IM node.exe
SUCCESS: The process “node.exe” with PID 13992 has been terminated.

What's the difference between netstat and Powershell's Get-Process

What's the difference between netstat and Powershell's Get-Process and why I'm getting different results?
For example, on my machine running netstat -a -n -o -b, one of the processes is
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:18882 0.0.0.0:0 LISTENING 13708
[System]
But running Get-Process I don't see any process with Id 13708.
Similarly, trying to kill this process (Stop-Process -Id 13708) returns an error message stating that:
Stop-Process : Cannot find a process with the process identifier
13708.
EDIT:
The process is started by starting a proxy server (Titanium-Web-Proxy) to capture browser traffic and the process I'm talking about remains in case the proxy is not stopped.

port forwarding in raspberry pi on debian

I want to forward incomings from 192.168.1.50:5007 to 10.1.1.117:5007 on raspberry pi debian installed . I do not want to make a bridge between two networks. How can I achieve this?
You can use ssh:
ssh -L 192.168.1.50:5007:10.1.1.117:5007 -N localhost
this assumes that your server is the machine at 192.168.1.50. if not, you're going to need to give me the IPs of all the machines involved and tell me which is which.
You'll need sshd running but you should already have that with Raspbian.
After you run it, you'll need to authenticate. No forwarding will occur until then.
Once you've logged in, it will look like it's hung, but it's not; it just doesn't have any output to show you.
At this point the forwarding is active.
You can kill it with ctrl-c when you're done.
If you'd rather keep it running in the background instead of having an empty window sitting around, you can use ctrl-z (which will pause its execution) followed by bg which will resume the process in the background.
To stop the forwarding from a backgrounded job, you're going to have to find the pid in ps and kill it.
Run netstat -ano --tcp |grep 5007 to see your server listening for connections on 192.168.1.50:5007, remote computers making connections to 192.168.1.50:5007, and new connections from your server to 10.1.1.117:5007

Could not bind to 0.0.0.0:8080, it may be in use or require sudo

Sometimes I get this error when trying to run a Vapor application from Xcode. Reopening Xcode doesn't help, only restarting of system do. Is it a bug of the framework? What should I do to prevent this?
If using sudo does not fix this message, it means something is already bound to this port. It could be an instance of Vapor that didn't close correctly.
To fix this, you need to kill the previous instance. The easiest way to do this is:
lsof -i tcp:8080
Where 8080 is the port you are trying to use. This outputs something like:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
com.apple 4679 tanner 8u IPv4 0x890f6b0b31966939 0t0 TCP
Then kill the process bound to that port using its PID.
kill -9 4679
While Tanner's answer should help in most cases, for me the kill command had no effect and no output. So I completely quitted & restarted terminal.
When running lsof there were no processes found anymore, and issue was solved.