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

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.

Related

Bind for 0.0.0.0:50000 failed: port is already allocated on MacOS

I initially ran jenkins in a docker container through my MacOS terminal successfully after running docker-compose up which generated the long admin password cypher. However after I restarted my machine, the setup vanished. But each time I run docker-compose up after exposing jenkins port 8080 on port 8082 and Jira port 50000 on port 200000 having tried exposing them externally on other ports previously, I keep getting the error below:
**Creating jenkins ... error
ERROR: for jenkins Cannot start service jenkins: driver failed programming external connectivity on endpoint jenkins (****************************************************): Bind for 0.0.0.0:20000 failed: port is already allocated
ERROR: for jenkins Cannot start service jenkins: driver failed programming external connectivity on endpoint jenkins (****************************************************): Bind for 0.0.0.0:20000 failed: port is already allocated**
I have stopped, killed and removed all containers, removed all images and pruned all networks, but nothing seems to work.
What's a way around this and how do I free up allocated ports?
You can find the process that is running on port 20000 using:
lsof:
lsof -nP -iTCP -sTCP:LISTEN | grep <port-number>
or
netstat:
netstat -anv | grep <port-number>
It is probably just an old process that stays as zombie. Just kill that process (you can use kill -9 <pid>) and try the same operation again.

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.

Cannot start Mongo DB server on MAC

I sometimes can start the mongodb server and sometimes I cannot. What is the real problem with my mongodb server. I am using Mac and I am getting this problem for the first time.
I tried to kill the mongodb process but it didn't help me.
Any possible solutions would be highly appreciated.
The error I am getting is below.
For killing the process, I tried to kill 27017 and it says no process found.
I think you are confusing port and PID. When you kill 27017, you send the SIGKILL signal to a process whose PID is 27017. However, unless there is a coincidence, mongod does not need to have that PID. 27017 is the default port for mongod instances.
To kill it properly do the following:
ps -edf | grep mongod --> get the PID of the mongod process
Then:
kill -SIGKILL <pid>
Then start it again.

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.

How to set nodejs debug mode don't listen 127.0.0.1

I want to remote debug the nodejs program in Eclipse. I start the node script with the debug option.
$node debug script.js
But I can't connect to the node in Eclispe. When I netstat the node's TCP port. I found that node only listen 127.0.0.1 in debug mode. So I can't connect it from different computer.
But I can't find any startup options that can change to listen to any address.
Anyone know to make it listen to any address to remote debug in other computer?
if anyone else stumble upon this: you can set the node debug to any address as you set the port
node --debug=169.168.1.2:5858 app.js
if that would be the ip of your remote machine or even better to every machine
node --debug=0.0.0.0:5858 app.js
but please be aware that the 2nd option should only be used if you are debugging in your own private network as you open it up for everyone
This is what I do in linux Debian:
install balancer
sudo apt-get install balance -y
then create a route in balancer to reroute your 5858 port to 5859
balance 5859 127.0.0.1:5858
start your app
node --debug app.js
now you can access it from everywhere on port 5859
I'm looking into V8 code that goes through deps/v8/src/debug-agent.* down to deps/v8/src/platform-posix.cpp (for linux) to POSIXSocket::Bind method and it can't seem to have any option about this (unless I'm missing something).
I bet you either hack it and recompile node or you'll need to build a small proxy beside your node process.
Here's a great tut on debugging nodejs from eclipse. Note at the bottom there is a script the author uses to forward localhost:5858 to the remote server's 127.0.0.1. You could also just use an SSH tunnel.
So, to summarize:
start your script with node --debug app.js
configure eclipse as if you were debugging locally
use the node_g script or configure an SSH tunnel
go on vacation now that your code is bug-free
to debug nodejs remotely over SSH session do:
1. install balance on Linux: https://balance.inlab.net/overview/
2. run the command: balance -df 8585 127.0.0.1:5858 > /tmp/balance.out 2>&1 &
3. ssh to your remote Linux box (tunnel will be created 8585 > 5858 > nodejs)
4. run your node script on server: node --debug-brk --nolazy ./myNodeApp.js
5. kick off debug session in WebStorm alt-d to port 8585
now you are remote debugging securely over SSH session