socket.gaierror: [Errno -2] Name or service not known
sys.argv[0] is not what you think it is. sys.argv[0] is the name of the program or script. The script's first argument is sys.argv[1].
socket.gaierror: [Errno -2] Name or service not known | Python
socket.gaierror: [Errno -2] Name or service not known
means that the name resolution is failing for the given domain (api.github.com
).
Name resolution (DNS in the usual notion) can fail for various reasons. As you have disconnected the internet, the reason is pretty obvious (Name or service not known
).
gai
(GetAddressInfo) is actually used by glibc
to perform the name resolutions, it's part of glibc
(and socket
is using that as you can imagine). You can also actually configure it in /etc/gai.conf
.
gai error at /home [Errno -2] Name or service not known
You've misunderstood the documentation to httplib. The parameter to instantiate the HTTPSConnection
is just the hostname. You then pass the actual path as the second param to request
. So:
connection = httplib.HTTPSConnection('rpxnow.com')
connection.request('POST', '/api/v2/auth_info', params)
Related Topics
Pyserial Works Fine in Python Interpreter, But Not Standalone
Running Python Script as a Systemd Service
/Usr/Bin/Env: Python2: No Such File or Directory
Python Linux Selenium: Chrome Not Reachable
How to Find the Target File's Full(Absolute Path) of the Symbolic Link or Soft Link in Python
How to Rewrite Output in Terminal
High Kernel CPU When Running Multiple Python Programs
Send Sigint in Python to Os.System
Running a Python Script Using Cron
What Are the Tkinter Events for Horizontal Edge Scrolling (In Linux)
Maltparser Giving Error in Nltk
A Simple Python Deployment Problem - a Whole World of Pain
Finding the Command for a Specific Pid in Linux from Python
How Does One Set Specific Vim-Bindings in Ipython 5.0.0
How to Read a (Static) File from Inside a Python Package
Run Python Script Only If It's Not Running
How to Split a Huge CSV File Based on Content of First Column