Local server refuses to connect

I just created Django on the dreamhost server. Go through everything but can't seem to get a welcome page. I got to the point where he says: β€œThe development server is running on 127.0.0.1:8002 (tried with 8000 but gotβ€œ this port is already in use ”). When I try to access this address in my browser in Chrome, I get error message 102 (net :: ERR_CONNECTION_REFUSED): the server refused the connection.

Any idea why this is happening? I'm stuck in a loop, I have no idea what's going on. Help is truly appreciated.

+4
source share
2 answers

You need to know the IP address of your server or domain. If you used example.com to access the SSH server, then start Django with

./manage.py runningerver 0.0.0.0:8002

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

0.0.0.0

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

+8
source

The problem is that django is listening on localhost , which means you cannot access the server directly over the Internet. To change this, you can specify the port / host name for django:

 ./manage.py runserver 0.0.0.0:8002 

If you do not want the server to be directly accessible over the Internet, you can perform port forwarding using ssh:

 ssh -L8002:localhost:8002 server 

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

+6
source

Source: https://habr.com/ru/post/1413033/


All Articles