pythonfastapi

fastAPI Python server not listening to port:8000


Hello am getting this error trying to start my python server what could be the solution

ERROR: [Errno 13] error while attempting to bind on address ('127.0.0.1', 8000): [winerror 10013] an attempt was made to access a socket in a way forbidden by its access permissions

trying to start a python server on port:8000 but its shutting itself down


Solution

  • There could be many different reasons behind this, such as:

    1. Another service is already using that port. So you should check if the port is being used by another program or not. netstat -aon | findstr :8000 This will return if any program is being using this 8000 port you should kill this.

    2. Run VS code or any other editor as Administrator: This could be another where if you had stored your code editor in diff file and your python in another file windows would give you permission issue. So try running as administrator and see if that fixed your problem or not.

    3. Firewall or Antivirus Blocking: Another reason could windows firewall or anti-virus software (if installed any) is blocking your port. So, try temporarily disabling your antivirus/firewall to see if the issue is resolved.

    P.S: There is a high chance your port is being used by another service or program, so simply changing to another port or killing 8000 port would solve your problem.