Reputation: 588
I got this error message sublime issue(My OS: Ubuntu 16.04
) "socket.error: [Errno 98] Address already in use"
If I run flask in sublime text or PyCharm. But if I run flask on my Ubuntu terminal,it is running. I understood that port used another service. Then i was trying to solve this issue from google/stackoverflow.
# ps ax | grep 5000 // or # ps ax | grep name_of_service
# kill 3750 // or # killall name_of_service
But nothing changed. Only i found this problem when i was trying to run on sublime or pycharm IDE.
Upvotes: 1
Views: 5944
Reputation: 1529
Simple way is to use fuser.
fuser <yourport>/tcp #this will fetch the process/service
Replace <yourport>
with the port you want to use
#to kill the process using <yourport> add `-k` argument
fuser <yourport>/tcp -k
In your case
fuser 5000/tcp -k
Now you can run flask with that port.
Upvotes: 6
Reputation: 176
Pycharm allows you to edit the run configuration, so enter the configuration and check the box (top-right corner) saying: "singleton instance". In this way, every time you restart the server, the previous connection on port 5000 is closed and opened again.
Upvotes: 1