11

So I'm a relative novice with Python, and just tried installing and running Django today. I'm working my way through the official tutorial, and when I try to run the python manage.py runserver I get Errno 10013: an attempt was made to access a socket in a way forbidden by its access permissions.

I am using Windows 7, and am running the cmd.exe console as an administrator. Could someone please explain how to fix this in plain english? The next step in the tutorial says to visit http://127.0.0.1:8000/ and that it should say Welcome to Django, but mine just brings up an error.

Thanks in advance for the help.

user1070381
  • 483
  • 2
  • 6
  • 9
  • 1
    Duplicate answer: http://stackoverflow.com/questions/2778840/socket-error-errno-10013-an-attempt-was-made-to-access-a-socket-in-a-way-forb – César Nov 29 '11 at 04:39

4 Answers4

53

The default port might be open in another program. Try the following:

python manage.py runserver 8080

If that doesn't work, it might be a permissions problem. Some people have reported that just running cmd.exe as admin isn't enough. There are a few fixes for this, but they're annoying and probably indicate something's weird with your Python install. Try the port fix first :-)

EDIT: Just read a blog post saying this is very common with folks running Aptana/PyDev. Aptana's internal webserver uses port 8000, which is the Django default.

Evan Brumley
  • 2,380
  • 18
  • 13
  • Superb bro...! You saved my day. – Maulik Dodia Jan 15 '17 at 09:48
  • Just tried this, and using port 8080 didn't work for me, but using port 9998 worked. – Paul Wildenhain Oct 25 '19 at 15:23
  • you wouldn't happen to know the resource for the annoying fixes that indicate something's weird with a Python install, would you? I'm still getting the error despite elevated privileges and the port itself being clear (I'm actually able to use runserver but it's failing after the fact on a call that should be working) – David Torrey Jan 07 '20 at 07:28
2

I had the same problem and I fixed it by running the code below in the cmd as an admin (to run as admin, right click on the powershell and and select 'run as admin').

python manage.py runserver 8080
Tunaki
  • 116,530
  • 39
  • 281
  • 370
Mubarak Awal
  • 340
  • 3
  • 21
2

Maybe this is because of some process is using this port so just kill this port and run again.

  1. go cmd
  2. netstat -a -n -o

Find your port number under the local address column.If u found,check the PID column.U will see which process is using this port

  1. taskkill /f /im [PID]

That is.

Jze
  • 1,692
  • 3
  • 14
  • 39
0

While I do not have McAfee installed, nor do am I on Windows 7 (both of which tend to problematic), I had an issue when running the line 'python manage.py runserver'. I had been receiving the error '10013'. The solution was moderately simple. To begin, run the line 'netstat -ano | findstr 127.0.0.1:8000', which checks the line of your port. If the command resulted in a message of any sort, then you ought to change the port which you're using. This can be done by adding a four digit number to the end of the original 'runserver' command.

Example: python manage.py runserver 7000 In the above example, the port being used was changed to port 7000.