django server refused connection on localhost - python

I have a brand new Django setup on my computer, I ran the command runserver, and I get an ERR_CONNECTION_REFUSED in chrome.
localhost is added to allowed_hosts and I get no error in django, when I check for the port it is not active.
I am running Django in wsl and accessing chrome from windows on the same machine
I have tried adding to my IP, changing browser, adding to allowed hosts, I initially had this issue in another project and I set up this new project to see if the problem would resolve, it didn't and the new project is completely clean no way something could be messed up there.
I tried running the server in windows and finally got an error
Error: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
I ran it with a whole lot of different port numbers which I am sure is not in used but no luck.
Any help would be greatly appreciated
edit 3: lol a simple restart of my computer did the trick, I guess it was a port blocking which is really weird because I tried dozens of ports and it didn't show up in use when I used netstat

Related

why is django server not working? (connection refused error)

I am doing a course : cs50 web programming with python and in project 2 Commerce while using
python manage.py runserver I am getting this error:
This site can’t be reached
127.0.0.1 refused to connect.
this is project 2 commerce. https://cs50.harvard.edu/web/2020/projects/2/commerce/
I have not made any changes to the distribution code
for my last project I was able to make it work by using this code in settings.py :
ALLOWED_HOSTS = ["ide-2f9427eaa96d41debb489eacf31c97d6-8080.cs50.ws"]
and changing url to the same
but on using it in this project I get this error:
403 Forbidden
edit
this is the solution I found from the comments:
As suggested in the comments I changed ALLOWED_HOSTS = [*] in settings.py of my django file.
then in the terminal I tried running the command python manage.py runserver 0.0.0.0:8080
On clicking the link I got a URL like this:
{ide URL}:8080
and this error:
This site can’t be reached
next I changed the URL manually to {IDE URL}-8080.cs50.wswhich is the URL for the web server in the IDE I am using.
this seemed to work for me.
The problem may have been because port 8000 is being used by another service and earlier I was not able to use port 8080 because I was using the wrong URL for my IDE's web server.
check settings.py and make sure debug is set to True. Then go to allowed hosts and set it to ['*'].
This will allow anyone on your system to connect to localhost server
By default the server runs on port 8000 so you might want to try 127.0.0.1:8000 in your URL

Cant connect to local host after successfully able to run django project in pycharm

I am able to Run "manage.py" in My Django Project and it successfully runs too. But I am unable to connect to local host in my browser. What could have gone wrong , Please explain?
Check if the port number is available or not. If not change the port number and try running again.

Heroku Django app: ECONNRESET: read ECONNRESET

I'm getting the below error when trying to run the command heroku run python manage.py migrate from the terminal.
ECONNRESET: read ECONNRESET
I followed the link in the heroku docs to check if there was a firewall issue, but I had a successful telnet connection. I haven't been able to find any other examples of anyone running into this issue unless they are having a proxy/firewall issue but according to the telnet test it doesn't seem like I have a problem right?
I've also tried testing any other heroku run command I can think of and I get the same result.
After reading the logs it showed that there was an Error Code R13. I was able to follow this thread to get what I needed to be fixed but was unable to run anything that needs to actually be attached (like an interactive shell).
Tried filing something with Heroku support but they basically said that it's outside the scope of free support. Disappointing.
The problem is related with a proxy in your internet connection.
Try to connect to heroku by using another internet connection, for example your mobile phone tethering.
It worked for me.
The problem is as a result of your internet connection provider blocking Heroku server. Change the source or provider of your internet and you will be able to connect to the Heroku Django console.

python, django, vagrant and access error on windows host machine

Well, I'm trying to access a python server (for django development) in a Virtual Box VM via vagrant, but I can't connect with it in my windows browsers. I'll try to describe all the things I've done to make this work, so maybe it can help you guys.
My configurations:
I set my vagrant file to allow connections in port 8000 (guest and host)
I have disabled my windows firewall.
I have turned off the firewall on the VM
I have disabled all chrome extensions (including addblock)
I have disabled almost all apps in my windows to minimize the chances that some program could use port 8000
I have unchecked "automatically detect settings" and "use a proxy server for your lan" in the lan settings (windows internet options), then done the ip /release, ip /renew and rebooted my machine
Yes, the python server is running well on the vm
I tried the default 127.0.0.1:8000 (no success) and changed to 0.0.0.0:8000 using the command "python manage.py runserver 0.0.0.0:8000", but still ... :(
I have a nginx server in the vm running well for my php apps in port 80, and i cant access them with no problems
I use pycharm for python development and it starts my server normally in the vm either using 127.0.0.1:8000 or 0.0.0.0:8000
I think that's it, but the error persists, I can't access my python server in my ip 192.168.56.101 in port 8000, this ip is my private network on the vm that runs good with nginx.
But the result is always the same
Whenever I try access http://192.168.56.101:8000/ all my browsers (IE, Firefox, Chrome) cannot complete the request, in Chrome the error is ERR_CONNECTION_TIMED_OUT
Thanks in advance for any help !
My problem was the firewall rules. I dont really need it since its a development environment, so I delete all the rules in /etc/iptables/rules.v4 and save the file. That solve it all. Tks.

How to use https for my application running on different port other than 443

My python application is running on port number 6666 on a linux machine to which I can connect using putty and I have sudo permissions to execute commands (I dont know root password)
1.If I change the port number in that application to 443 and if I run that application then getting some permission denied error at the time of socket binding
2.and if I use sudo for the above case then getting some module not found error.
If I open https://that_server_name:6666/path_to_my_appln from my localhost, then getting the error as cound not find response (as I am able to successfully run my application with port 6666, I ran the application and I tried to open that url)
or else if I open https://that_server_name:443/path_to_my_appln , then getting error as 503, service temporarily unavailable(as I am getting above mentioned errors for port number 443, so I did not start my application in backend)
My question is how to map 443 to an application running on 6666 port
In order to listen to a port below 1024 on Linux you need to have root permissions. You can
Run the program as root and secure it, for example by dropping privileges after binding to the socket.
Use a webserver (Apache, nginx, ...) to proxy the request.
Of cause there are some more solutions.
You should try to solve the problem of module not found error. That would be a good solution to your problem. If you post your module not found error that would be helpful. How are you running the Python application. Are you running it from a virtualenv?

Categories

Resources