1

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.

2 Answers 2

4

Run runserver with the domain name instead of the IP:

python manage.py foobar.com:8000 

Remember that you most definitely shouldn't use runserver in production:

DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)

Sign up to request clarification or add additional context in comments.

2 Comments

run server with domain fails again. This is just a test, my production env is using nginx/uwsgi but have the same problem. :(
any more suggestions?
0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.