python httplib Name or service not known

南笙酒味 提交于 2019-11-28 09:24:27
oarevalo

As an (obvious) heads up, this same error can also be triggered by including the protocol in the host parameter. For example this code:

conn = httplib.HTTPConnection("http://secure.authorize.net", 80, ....)  

will also cause the "gaierror: [Errno -2] Name or service not known" error, even if all your networking setup is correct.

gaierror: [Errno -2] Name or service not known

This error often indicates a failure of your DNS resolver. Does ping secure.authorize.net return successful replies from the same server that receives the gaierror? Does the hostname have a typo in it?

The problem ultimately came down to the fact that selinux was stopping apache from getting that port. Disabling selinux fixed the problems. I had an issue later where i didn't have /var/www/.python-eggs/, so MySQLdb was hosing on import. But after a mkdir, it was fixed.

pass the port separately from the host:

conn = httplib.HTTPSConnection("secure.authorize.net", 443, ....)  
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!