0

I am trying to open a page using urllib2 but i keep getting connection timed out errors.

url = "http://" + "100.12.13.11/api.php"
f = urllib2.urlopen(url)

I have two static IPs: 100.12.13.12, LAN IP - 10.10.209.2, domain - test.com; and 100.12.13.11 , LAN IP - 10.10.209.1, domain - test2.com.

When I access

http://100.12.13.11/api.php

from the server at 100.12.13.12 using urllib2, it says connection timeout error.

Also if I use the domain, for example

http://test.com/api.php 

the same thing happens but it works whenever I use the LAN IP

http://10.10.209.1/api.php

(both of the static IPs are in the same network)

The problem doesn't occur whenever I access from outside the network. But, in PHP, it works for domain name, static IP and LAN IP.

Does anyone know why this strange thing is happening?

2
  • Could you please better describe your problem? I do not understand how you tested that the "server" accept connections from your "client" before pointing to a python issue. Also, you example cannot be functional, it misses quotes and the (presumably) "http://" prefix so urllib2 knows which port and protocol to use. Commented Jan 8, 2014 at 11:31
  • i already uses http:// but it does not respond but i access same url with different programming language for example php it works Commented Jan 9, 2014 at 4:38

1 Answer 1

1

Usually LAN's disallow local access to global IP's or domains hosted locally.Solution is to map the global hostname to the local IP in your local DNS.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.