garg10may
garg10may

Reputation: 6179

Start HTTP/HTTPS server, python -m SimpleHTTPServer

I am trying to start HTTPS server on my localhost, but getting below error. I have opened cmd as an administrator.

C:\Windows\system32>python -m SimpleHTTPServer
Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\lib\SimpleHTTPServer.py", line 224, in <module>
    test()
  File "C:\Python27\lib\SimpleHTTPServer.py", line 220, in test
    BaseHTTPServer.test(HandlerClass, ServerClass)
  File "C:\Python27\lib\BaseHTTPServer.py", line 595, in test
    httpd = ServerClass(server_address, HandlerClass)
  File "C:\Python27\lib\SocketServer.py", line 419, in __init__
    self.server_bind()
  File "C:\Python27\lib\BaseHTTPServer.py", line 108, in server_bind
    SocketServer.TCPServer.server_bind(self)
  File "C:\Python27\lib\SocketServer.py", line 430, in server_bind
    self.socket.bind(self.server_address)
  File "C:\Python27\lib\socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 10013] An attempt was made to access a socket in a way forb
idden by its access permissions

Upvotes: 2

Views: 1895

Answers (2)

garg10may
garg10may

Reputation: 6179

I was not able to start since some service is already running on 8000, I was able to successfully start the service on another port 2000

C:\>python -m SimpleHTTPServer 2000
Serving HTTP on 0.0.0.0 port 2000 ..

One can get the PID/status for port 8000 by netstat -ano

C:\>netstat -ano

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP    0.0.0.0:912            0.0.0.0:0              LISTENING       2544
  TCP    0.0.0.0:8000           0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:19781          0.0.0.0:0              LISTENING       3100

shows PID 4 which is a system process.

Upvotes: 2

ApriOri
ApriOri

Reputation: 2688

Your windows firewall may block python from listening. Additionaly, try adding a different port number higher than 1024 to the command line and see if it helps.

Upvotes: 4

Related Questions