Tiany Wang Tiany Wang - 2 months ago 20
Python Question

why access by ip is ok but domain fails?

I start a new Django APP on a server with public IP, then run it with command:


python manage.py runserver publicip:port


then I found when i access it with
http://publicip:port
it works fine.
but when I access it using the domain name (which is resolved to this ip), it fails,
and gives the blow errors:(https://dpaste.de/FIrk)

0 errors found
October 10, 2013 - 10:31:13
Django version 1.5.1, using settings 'testsite.settings'
Development server is running at http://*.*.*.*:8709/
Quit the server with CONTROL-C.

Traceback (most recent call last):
File "/usr/lib/python2.7/wsgiref/handlers.py", line 86, in run
self.finish_response()
File "/usr/lib/python2.7/wsgiref/handlers.py", line 127, in finish_response
self.write(data)
File "/usr/lib/python2.7/wsgiref/handlers.py", line 210, in write
self.send_headers()
File "/usr/lib/python2.7/wsgiref/handlers.py", line 268, in send_headers
self.send_preamble()
File "/usr/lib/python2.7/wsgiref/handlers.py", line 189, in send_preamble
self._write('HTTP/%s %s\r\n' % (self.http_version,self.status))
File "/usr/lib/python2.7/wsgiref/handlers.py", line 389, in _write
self.stdout.write(data)
File "/usr/lib/python2.7/socket.py", line 324, in write
self.flush()
File "/usr/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 104] Connection reset by peer
----------------------------------------
Exception happened during processing of request from ('58.33.144.118', 53268)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 582, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 150, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "/usr/lib/python2.7/SocketServer.py", line 640, in __init__
self.finish()
File "/usr/lib/python2.7/SocketServer.py", line 693, in finish
self.wfile.flush()
File "/usr/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
----------------------------------------


Can anyone give some suggestions to find out why, thx a lot.

Answer

It has been a long time, but i think i should write this down for others who has the same problem.

It is because the domain name is not BeiAn(备案) in China, and the ISP blocked access to this server.