Kaleab Woldemariam
Kaleab Woldemariam

Reputation: 2993

'WinError 10013' running Django on Windows

It has been almost a month since I got this problem, and I really appreciate your help. While trying to login in my Django Web App, i encounter OSError at /accounts/login/.I am able to login in 127.0.0.1:8000/admin, but not in the /accounts/login which produces the Error Code:

OSError at /accounts/login/
[WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

Request Method: POST
Request URL:    http://127.0.0.1:8000/accounts/login/
Django Version: 1.11.1
Exception Type: OSError
Exception Value:    
[WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
Exception Location: C:\Python35-32\lib\socket.py in create_connection, line 702
Python Executable:  C:\Python35-32\myvenv_python3\Scripts\python.exe
Python Version: 3.5.2
Python Path:    
['C:\\Users\\Kaleab\\Desktop\\ecomstore',
 'C:\\Python35-32\\lib\\site-packages\\sqlalchemy-1.1.7-py3.5-win32.egg',
 'C:\\Python27',
 'C:\\Python35-32\\myvenv_python3\\Lib\\site-packages',
 'C:\\Python35-32',
 'C:\\Users\\Kaleab\\Desktop\\ecomstore',
 'C:\\Python35-32\\myvenv_python3\\Scripts\\python35.zip',
 'C:\\Python35-32\\DLLs',
 'C:\\Python35-32\\lib',
 'C:\\Python35-32\\myvenv_python3\\Scripts',
 'C:\\Python35-32\\lib\\site-packages',
 'C:\\Python35-32\\lib\\site-packages\\win32',
 'C:\\Python35-32\\lib\\site-packages\\win32\\lib',
 'C:\\Python35-32\\lib\\site-packages\\Pythonwin']
 

Possible Causes and Solutions

  1. Cause: Socket access needs administrative privilege. Attempted Solution: • Granted Administrator access to python.exe by navigating to the virtual environment. • Navigate to CMD.exe , right click , properties, grant administrator privilege.

  2. Cause: Port can be already used by another program. Attempted Solution: Checked the ports using TCPView windows program and see that the port 8000 is not used by another program.

  3. Cause: Socket access blocked by Firewall and Antivirus. Attempted Solution: When I tried disabling Firewall and Antivirus, I get another error ConnectionRefusedError at accounts/login/ [WinError 10061] No connection could be made because the target machine actively refused it.

  4. Cause: Winsock has malfunctioned. Attempted Solution: Tried and successfully reset winsock, but this did not solve it either.

Upvotes: 12

Views: 22989

Answers (8)

Paul Cleghorn
Paul Cleghorn

Reputation: 31

I solved this using a different port:

python manage.py runserver 9999

9999 Worked for me

Upvotes: 2

black_hole_sun
black_hole_sun

Reputation: 956

I got the Error Message due to my Antivirus App (Kaspersky). All i had to do was to assign manage.py in Kasperky < manage programms to trustworthy. I have a foreign version so trustworthy is a literal translation, maybe in the english version it is named different.

Upvotes: 0

David Louda
David Louda

Reputation: 577

It is possible that you have another process running that is using the port. Finding and killing the process will enable you to use the 8000 port.

Upvotes: 0

vik
vik

Reputation: 51

Just restart your computer and run
python manage.py runserver
or
python manage.py runserver PORT_NUMBER
or
python manage.py runserver 8000
or
python manage.py runserver 8080

Upvotes: 0

Sadhana Singh
Sadhana Singh

Reputation: 195

run the command with port number 8080 as follows

python manage.py runserver 8080

Upvotes: 0

Amit nayal
Amit nayal

Reputation: 51

Changing the port worked for me, I was trying to run the django server. Its not a firewall issue just type port in front of your command

python manage.py runserver 7000

Upvotes: 5

Neal Gokli
Neal Gokli

Reputation: 485

Since changing the port worked for @Kaleab, the problem may have been another process using that port.

I just found a Firefox process with a loopback connection from port 5000 to port 5000 (strange?). Once I closed Firefox, I was able to start my Flask server without that error.

To find out which process is using the port, see here.

Upvotes: 0

Kaleab Woldemariam
Kaleab Woldemariam

Reputation: 2993

I will take running the server with different port as the answer, although I am not able to see port 8000 is used in stackoverflow suggested commands. Use: python manage.py runserver 8080.

Upvotes: 16

Related Questions