There is an answer in OP’s comments based on another question, which requires to edit /etc/hosts
, i.e echo 127.0.0.1 $HOSTNAME >> /etc/hosts
.
Alternatively, you can use socket.gethostbyname('localhost')
, assuming that localhost
is what you need and it is defined in your /etc/hosts
.
Related Posts:
- Python [Errno 98] Address already in use
- Error: nodename nor servname provided, or not known (python sockets)
- gaierror: [Errno 8] nodename nor servname provided, or not known (with macOS Sierra)
- What does socket binding mean?
- Python socket.error: [Errno 111] Connection refused
- python socket programming OSError: [WinError 10038] an operation was attempted on something that is not a socket
- Sending string via socket (python)
- Getting “socket.error: [Errno 61] Connection refused” python paramiko
- Errno 10061 : No connection could be made because the target machine actively refused it ( client – server )
- How to set timeout on python’s socket recv method?
- Python Socket Receive Large Amount of Data
- UDP Client/Server Socket in Python
- Handling a timeout error in python sockets
- Purpose of “%matplotlib inline”
- How do I update Anaconda?
- TypeError: ‘str’ object is not callable (Python)
- Dijkstra’s algorithm in python
- How to create a GUID/UUID in Python
- Replace ‘ with \’ in a string
- How can I install pip on Windows?
- Best way to convert string to bytes in Python 3?
- Does Python have a string ‘contains’ substring method?
- Difference between import numpy and import numpy as np
- No module named ‘sklearn.cross_validation’
- Are static class variables possible in Python?
- Why am I getting “LinAlgError: Singular matrix” from grangercausalitytests?
- ‘method’ object is not subscriptable. Don’t know what’s wrong
- How do I copy a file in Python?
- EOFError: Ran out of input
- Get Color Palettes from ColorHunt.co in Python
- What does the Pydoc module do?
- size of NumPy array
- Best way to strip punctuation from a string
- How can I explicitly free memory in Python?
- filename.whl is not supported wheel on this platform
- What is the meaning of [:] in python [duplicate]
- Finding and replacing elements in a list
- socket.error: [Errno 48] Address already in use
- How to determine a Python variable’s type?
- Could not find a version that satisfies the requirement
- Removing Conda environment
- Cannot convert list to array: ValueError: only one element tensors can be converted to Python scalars
- How do I plot only a table in Matplotlib?
- Change column type in pandas
- Split by comma and strip whitespace in Python
- How to remove punctuation marks from a string in Python 3.x using .translate()?
- Calculating Covariance with Python and Numpy
- What is the easiest way to remove all packages installed by pip?
- In practice, what are the main uses for the new “yield from” syntax in Python 3.3?
- Subplot for seaborn boxplot
- Dump a NumPy array into a csv file
- Add a new item to a dictionary in Python
- reducing number of plot ticks
- How can I add new keys to a dictionary?
- Convert pandas data frame to series
- Decorators with parameters?
- How do I get a python program to do nothing?
- inserting characters at the start and end of a string
- How can I install Python’s pip3 on my Mac?
- Error handling in Python-MySQL
- List files ONLY in the current directory
- No Module Named ‘_pywrap_tensorflow_internal’
- Pop index out of range
- No module named Image
- How to fix “TypeError: len() of unsized object”
- ValueError: Unknown projection ‘3d’ (once again)
- Difference between len() and .__len__()?
- Python: AttributeError: ‘_io.TextIOWrapper’ object has no attribute ‘split’
- How to detect key presses?
- isPrime Function for Python Language
- Python script to copy text to clipboard
- How can I check if character in a string is a letter? (Python)
- OSError: Initializing from file failed on csv in Pandas
- TypeError: unsupported format string passed to list.__format__
- python setup.py uninstall
- ImportError: No module named cv2
- ./xx.py: line 1: import: command not found
- How do I run pip on python for windows?
- Python iteration over non-sequence
- How do I convert a string to a double in Python?
- _csv.Error: field larger than field limit (131072)
- How do I rotate an image around its center using Pygame?
- How can I copy a Python string?
- Issue with virtualenv – cannot activate
- Can I set max_retries for requests.request?
- Why do I get this error “TypeError: ‘method’ object is not iterable”?
- How to obfuscate Python code effectively?
- Controlling mouse with Python
- Are nested try/except blocks in Python a good programming practice?
- Getting a name error when trying to input a string [duplicate]
- Complex number troubles with numpy
- Running shell command and capturing the output
- Line is too long. Django PEP8
- TypeError: zip argument #2 must support iteration
- CS231n: How to calculate gradient for Softmax loss function?
- How to create a new database using SQLAlchemy?
- Python 3 integer division [duplicate]
- numpy/scipy/ipython:Failed to interpret file as a pickle
- What is the Python equivalent of static variables inside a function?
- Python – difference between two strings