Introduction
As the execution of a command for starting the Django-based application is running, an error appear. The execution of this command exist in a PC or a laptop which is using a Microsoft Windows 10 as its operating system. The error with the execution of the command for starting the Django-based application exist as follows :
C:\python\django>python manage.py runserver 5000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). January 06, 2022 - 21:00:04 Django version 3.2.6, using settings 'core.settings' Starting development server at http://127.0.0.1:5000/ Quit the server with CTRL-BREAK. Error: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions C:\python\django>
Solution
The solution is easy. Actually, the error above in the introduction part is because of the parameter of the command. Basically, by default, the Django command for starting the internal Django server do not need for any additional port. But in this case, if there is a requirement to run the internal Django server in another port, an additional port which is becoming the parameter of the command is necessary. But not every port number is available. Such as in the above introduction part. It is using a non-default port of 5000 where the default port is 8000.
So, instead of using port 5000 which maybe is not available, just use another port. In order to prove it, the following are the steps :
-
Take for instance another port which is currently not available. That port is for an example a default port of MySQL database server which is running in port 3306. The following is the attempt to execute it :
C:\python\django>python manage.py runserver 3306 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). January 06, 2022 - 21:00:04 Django version 3.2.6, using settings 'core.settings' Starting development server at http://127.0.0.1:3306/ Quit the server with CTRL-BREAK. Error: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions C:\python\django>
-
Since it is becoming the cause of the error message, just find out any other ports which is available for running the Django internal server with a non-default port. For an example by using port 9000. Just start execute it as follows :
C:\python\django>python manage.py runserver 9000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). January 06, 2022 - 21:44:19 Django version 3.2.6, using settings 'core.settings' Starting development server at http://127.0.0.1:9000/ Quit the server with CTRL-BREAK.
Fortunately, it is working.