1

I am running Flask in Pycharm. Suddenly I can no longer run the framework properly! I get a bunch of error messages that ends with:

socket.error: [Errno 48] Address already in use

It seems like the socket Flask is using:

"http://127.0.0.1:5000/" 

And it is somehow not available anymore because the last runtime was not shut down properly. I can probably restart my computer and it will probably be a solution, but I don't want to do that if it happens regularly. How do I shut it down?

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
Arash Saidi
  • 2,228
  • 20
  • 36

4 Answers4

1

If you're running Linux, do a ps aux | grep python and kill the process that is running flask. If you're running windows, open task manager and kill the python process running flask, but you might have to kill PyCharm.

Eric Workman
  • 1,425
  • 12
  • 13
  • 1
    Thanks, that worked! In addition, I would point out that when you do {ps aux | grep python} you get a list of all running processes, and the number on the far left (after username) is the process id. You can then do the command: kill processid – Arash Saidi May 23 '14 at 10:12
  • Yes. You could do a `pkill -f ` as well, but picking out the process name isn't always the easiest thing to do. – Eric Workman May 23 '14 at 11:45
1

You can also click the red square button to stop the run (or command-F2 on a mac). If it fails to stop, you'll get a skull icon to kill the process.

hilyas
  • 11
  • 1
1

This happened to me a few times. I eventually found it to be as simple as to just Run > Stop 'server' in PyCharm.

Anton
  • 13
  • 3
0

You want to actively stop the process running your Flask application. Pycharm documentation describes this. Essentially, Pycharm will run applications internally and keep them running for you, so you can do testing or other tasks. Notably, each debugging run will start it's own process - so shutting these down will release resources.

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102