tags:

views:

533

answers:

4

Often, when restarting Django runserver, if I use the same port number, I get a 'port is already in use' message. Subsequently, I need to increment the port number each time to avoid this.

It's not the case on all servers, however, so I'm wondering how I might achieve this on the current system that I'm working on?

BTW, the platform is Ubuntu 8.10

+3  A: 

You're getting that message because the server is already running (possibly in the background). Make sure to kill the process (bring it to the foreground and press ctrl-c) to stop the process.

mipadi
right! I think I've been using ctrl-z!
Antonius Common
Ctrl+z is undo. If you don't see a command prompt, your server is still running.
Soviut
ctrl-z puts a process in the background, so one could see a command prompt, even though the server is still running (in the background).
mipadi
+1  A: 

Like mipadi said, you should be terminating the server (ctrl+c) and returning to the command prompt before calling manage.py runserver again.

The only thing that could be disrupting this would be if you've somehow managed to make runserver act as a daemon. If this is the case, I'm guessing you're using the Django test server as the actual web server, which you should NOT do. The Django test server is single threaded, slow and fragile, suitable only for local development.

Soviut
no, I've had this problem too... specifially when allowing eclipse to manage terminating the test server... I think it might happen as a result of something in the test server freezing up
Jiaaro
I'd recommend simply starting the test server and letting it run. It automatically detects changes to your python files and restarts itself. No need to hit a 'run' button.
Soviut
A: 

No, he's not an idiot guys. Same thing happens to me. Apparently it's a bug with the python UUID process with continues running long after the django server is shutdown which ties the port up.

I have the same issue in leopard.I close it with Ctrl-C and still the port is blocked.
mamcx
A: 

In Leopard, I bring on the Activity Monitor and kill python. Solved.

mamcx