Localhost Server Refusing Connection

烈酒焚心 提交于 2019-12-21 12:29:49

问题


I just set up Django on a dreamhost server. Ran through everything, but can't seem to get the welcome page. I got to the point where it says "Development server is running at 127.0.0.1:8002 (tried with 8000 but got the "that port is already in use error). When I try to access that address in my browser in Chrome I get Error 102 (net::ERR_CONNECTION_REFUSED): The server refused the connection.

Any idea why this is happening? I am stuck in a loop, I have no clue what is going on. Help is sincerely appreciated.


回答1:


You need to know your server's IP or domain address. If you used example.com to access you server SSH, then launching Django with

./manage.py runserver 0.0.0.0:8002

and accessing it with http://example.com:8002 should work. But if you only know IP, then launch Django with that IP instead of

0.0.0.0

and access it with http://YOUR-IP:8002




回答2:


The problem is that django is listening on localhost this means you won't be able to access the server directly via the internet. To change that you can specify the port/hostname for django:

./manage.py runserver 0.0.0.0:8002

If you don't want to make the server directly accessible via the internet you can do port forwarding with ssh:

ssh -L8002:localhost:8002 server

This will forward your local port 8002 via ssh to the remote server.



来源:https://stackoverflow.com/questions/10640720/localhost-server-refusing-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!