Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localhost Server Refusing Connection

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.

like image 422
Kyle Avatar asked May 17 '12 17:05

Kyle


People also ask

Why can't I connect to my localhost server?

If you're unable to access the web server via localhost, there's a chance that your firewall may be blocking the connection. You can often resolve this problem by modifying your firewall settings to allow incoming connections for the port that MAMP is trying to access.

What to do if localhost is not working?

Another possibility for localhost not working is a corrupted HOSTS file. Try deleting it and recreating it with an editor that is not notepad. that activates the new entries in your hosts file.

Why is 127.0 0.1 refused to connect?

0.1 (loopback address). So your client is trying to connect to any of the non-loopback addresses of your machine, while your server is listening only on the loopback address . So, no connection can be established. The solution to this problem is that connect to the same end point your server is listening on.


1 Answers

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

like image 84
and3p Avatar answered Sep 22 '22 13:09

and3p