Reputation: 2993
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
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.
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.
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.
Cause: Winsock has malfunctioned. Attempted Solution: Tried and successfully reset winsock, but this did not solve it either.
Upvotes: 12
Views: 22989
Reputation: 31
I solved this using a different port:
python manage.py runserver 9999
9999
Worked for me
Upvotes: 2
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
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
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
Reputation: 195
run the command with port number 8080 as follows
python manage.py runserver 8080
Upvotes: 0
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
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
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