URLError: urlopen error timed out - python

Whenever i try to make a HTTP request to some url through my django application which is running on top of apache mod_python (Machine: Ubuntu 10.04 server edition, 64-bits), it gives a timeout error.
The strange thing is that it works fine on Ubuntu 10.04 server edition, 32-bits.
I feel there could be some proxy connection issue. But i am not sure how to resolve it, if that is the case.
What could be the issue? Can anyone please throw some light on this.
Thanks in Advance.

Run simple network analysis first,
tracert
ping
wireshark (for network analysis)
Check your firewall and proxy settings on the server and make sure the correct ports, routes and permissions are fine.

Step 1:
Try it in the python shell first. Just take whatever you're trying to do with urlopen and do it in the python shell. You need to simplify your test.
Step 2:
If it still doesn't work maybe it's network... trying pinging the domain.
# ping domain.com
Could be a DNS issue, try looking the domain up:
# nslookup domain.com
or
# dig domain.com
If this works try pinging the IP directly.
# ping 000.000.000.000
Without more details this is all I know to try.

Related

Python API Max retries ecceeded [duplicate]

File "C:\Python27\lib\socket.py", line 224, in meth
return getattr(self._sock,name)(*args) gaierror: [Errno 11004]
getaddrinfo failed
Getting this error when launching the hello world sample from here:
http://bottlepy.org/docs/dev/
It most likely means the hostname can't be resolved.
import socket
socket.getaddrinfo('localhost', 8080)
If it doesn't work there, it's not going to work in the Bottle example. You can try '127.0.0.1' instead of 'localhost' in case that's the problem.
The problem, in my case, was that some install at some point defined an environment variable http_proxy on my machine when I had no proxy.
Removing the http_proxy environment variable fixed the problem.
The problem in my case was that I needed to add environment variables for http_proxy and https_proxy.
E.g.,
http_proxy=http://your_proxy:your_port
https_proxy=https://your_proxy:your_port
To set these environment variables in Windows, see the answers to this question.
Make sure you pass a proxy attribute in your command
forexample - pip install --proxy=http://proxyhost:proxyport pixiedust
Use a proxy port which has direct connection (with / without password). Speak with your corporate IT administrator. Quick way is find out network settings used in eclipse which will have direct connection.
You will encouter this issue often if you work behind a corporate firewall. You will have to check your internet explorer - InternetOptions -LAN Connection - Settings
Uncheck - Use automatic configuration script
Check - Use a proxy server for your LAN. Ensure you have given the right address and port.
Click Ok
Come back to anaconda terminal and you can try install commands
May be this will help some one. I have my proxy setup in python script but keep getting the error mentioned in the question.
Below is the piece of block which will take my username and password as a constant in the beginning.
if (use_proxy):
proxy = req.ProxyHandler({'https': proxy_url})
auth = req.HTTPBasicAuthHandler()
opener = req.build_opener(proxy, auth, req.HTTPHandler)
req.install_opener(opener)
If you are using corporate laptop and if you did not connect to Direct Access or office VPN then the above block will throw error. All you need to do is to connect to your org VPN and then execute your python script.
Thanks
I spent some good hours fixing this but the solution turned out to be really simple. I had my ftp server address starting with ftp://. I removed it and the code started working.
FTP address before:
ftp_css_address = "ftp://science-xyz.xyz.xyz.int"
Changed it to:
ftp_css_address = "science-xyz.xyz.xyz.int"

ngrok doesn't work in some particular case

I'm tunneling with ngrok to access my localhost of remote desktop.
I successfully created my forwarding URL with ngrok but it doesn't seem it works well.
Let's say when I do this https://*******.ngrok.io/sentiment/楽 I get what I want.
But when I do this https://*******.ngrok.io/sentiment/楽しい I get bad request error but the url actually perfectly returns output on localhost of remote desktop.
I don't know what's just different, is there any encoding problem or something? I'm so in trouble. thanks.

Django tutorial: problems accessing development server

I am going through the Django tutorial and am running into problems when trying to view my webpage. I am at the very beginning of the tutorial when I first run the command python manage.py runserver xxx.xxx.xxx.xxx:8000 (replace the x's with my remote server's IP). When I try to navigate to http://xxx.xxx.xxx.xxx:8000 on my local machine, Chrome gives me the error ERR_CONNECTION_REFUSED. I have also tried running the server on 0.0.0.0:8000 and the same issue persists. The port is definitely open and there are no firewalls blocking it - when I plug in my IP and 8000 into this site it claims it is open: http://ping.eu/port-chk/.
I get no error messages on my console from the Django side of things. What could be causing this error? I really don't know much about servers or ports. Thanks in advance.
I am on a virtual Linux server running CentOS 6.4. My local machine is running Mac OS 10.9.5
EDIT:
When I run netstat --listen, port 8000 doesn't show up in the Local Address column, even though my Django dev server claims to be running. Someone mentioned to me that this means my application is not listening on this port. What does this mean and how do I remedy it?
EDIT:
I can access the page through my phone's internet with no issues. What gives?
If you're running Django inside a VM but accessing it from the host Mac, you'll need to forward the port. See the settings in Virtualbox/VMWare/whatever.
Note however that Django runs perfectly well directly on a Mac, so if you're just learning it may be simpler to just install it there.
Don't issue no IP, runserver will tell you where you can connect to when launching it.
Since you're launching it from your VM, you might supply the IP.
Ensure system level routing is okay.
Add your host local IP to the ALLOWED_HOSTS setting.

cherrypy and IIS 7

How can I deploy cherrypy along with IIS. I am not able to reach the machine from outside using the IP. If i run using localhost it works. If I give the ip address in the browser from a different machine then IIS7 comes up.
Thanks
Raman
It would help if you posted more information about your problem but this kinda sounds like a classic configuration issue. If you have CherryPy listening on localhost (127.0.0.1) then it will only answer on that address. You have to configure it to listen on the external IP address if you want it to answer there. Here is another question that covers how to do this.
It also sounds like you are trying to run CherryPy on a box that also has IIS7 running. If this is the case, and you wish to continue to run both, you will either need to configure CherryPy to use a different port than IIS7 or you will have to configure IIS7 to redirect requests to CherryPy. Here is a similar question about doing the latter with IIS6

Troubles with http server on linux

I have such problem. I have local http server (BottlePy or Django), and when i use http:// localhost/ or http:// 127.0.0.1/ - it loads immediately. But when i use my local ip (192.168.1.100), it loads very long time (some minutes). What could be the problem?
Server works on Ubuntu 11.
you should take a look at
Slow Python HTTP server on localhost
similar issues has been resolved there.
It looks like that you have problems with DNS. can you check this idea running host 192.168.1.100 on the host? Please also check that other DNS queries being quickly processed.
Check /etc/hosts file for a quick-and-dirty solution.

Categories