2

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
garg10may
  • 5,794
  • 11
  • 50
  • 91
  • Have you looked this up? There are a lot of results on the Google. I'm not going to close as duplicate because I don't know enough to make the judgement, but I'd expect you to at least point out how they don't apply when asking the question. – Veedrac Sep 21 '14 at 05:05
  • Yes saw answers which discuss trying telnet, i get below error, C:\Windows\system32>telnet 127.0.0.1 80 'telnet' is not recognized as an internal or external command, operable program or batch file. Also changed from normal to admin account still same erorr, simultaneously reading over if something works. – garg10may Sep 21 '14 at 05:08

2 Answers2

4

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.

ApriOri
  • 2,618
  • 29
  • 48
  • If unspecified, `SimpleHTTPServer` uses port 8000. – falsetru Sep 21 '14 at 05:16
  • Ok it started on port 2000, but how can I ensure if some process in running on 8000 and how do I stop that, does running on different port matters. – garg10may Sep 21 '14 at 05:24
  • @ApriOri is shows systemprocess with PID 4, firewall is definitely not blocking, since when I started on port 2000 it poped up and I allowed it. – garg10may Sep 21 '14 at 05:55
2

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.

garg10may
  • 5,794
  • 11
  • 50
  • 91