import socket socket.gethostbyname(socket.gethostname())
This won’t work always (returns 127.0.0.1
on machines having the hostname in /etc/hosts
as 127.0.0.1
), a paliative would be what gimel shows, use socket.getfqdn()
instead. Of course your machine needs a resolvable hostname.
Related Posts:
- What does localhost:8080 mean?
- Is it possible to repeat or redistribute a Bluetooth signal? [closed]
- java.net.ConnectException: Connection refused
- How can you find out which process is listening on a TCP or UDP port on Windows?
- java.net.ConnectException :connection timed out: connect?
- What is the difference between a port and a socket?
- Does TCP send a SYN/ACK on every packet or only on the first connection?
- Sending string via socket (python)
- What is the quickest way to HTTP GET in Python?
- Docker-compose container using host DNS server
- UDP vs TCP, how much faster is it?
- Android check internet connection
- How do I get Flask to run on port 80?
- How does IPv4 Subnetting Work?
- I’ve inherited a rat’s nest of cabling. What now?
- What is the difference between Unix sockets and TCP/IP sockets?
- Why couldn’t MAC addresses be used instead of IPv4|6 for networking? [closed]
- VirtualBox: How to set up networking so both host and guest can access internet and talk to each other
- How do VLANs work?
- What causes the ‘Connection Refused’ message?
- How does IPv6 subnetting work and how does it differ from IPv4 subnetting?
- Why do consoles sometimes hang forever when SSH connection breaks?
- Switching to IPv6 implies dropping NAT. Is that a good thing?
- How much network latency is “typical” for east – west coast USA?
- How do I find if there is a rogue DHCP server on my Network?
- Is X.Y.Z.0 a valid IP address?
- What is this IP address: 169.254.169.254?
- ssh tunnel refusing connections with “channel 2: open failed”
- How do I make a connection private on Windows Server 2012 R2
- Should network hardware be set to “autonegotiate” speeds or fixed speeds?
- What is “anycast” and how is it helpful?
- What happens when you plug two sides of a cable to a single networking device?
- How to reload default Mac OSX routing table without rebooting
- TypeError: only size-1 arrays can be converted to Python scalars (matplotlib)
- Why do I get TypeError: can’t multiply sequence by non-int of type ‘float’?
- Writing a pandas DataFrame to CSV file
- What is the difference between range and xrange functions in Python 2.X?
- How do I install pip on macOS or OS X?
- What is the necessity of plt.figure() in matplotlib?
- When should I use uuid.uuid1() vs. uuid.uuid4() in python?
- ImportError: No module named tensorflow
- Best way to convert string to bytes in Python 3?
- How do you change the size of figures drawn with Matplotlib?
- PermissionError: [Errno 13] Permission denied
- Expected 2D array, got 1D array instead error
- syntaxerror: “unexpected character after line continuation character in python” math
- How to prevent errno 32 broken pipe?
- The equivalent of a GOTO in python [duplicate]
- tkinter gui with progress bar
- Invalid character in identifier
- if else in a list comprehension
- What does “\r” do in the following script?
- Convert list to tuple in Python
- How to enable CORS in flask
- Python: TypeError: object of type ‘NoneType’ has no len()
- anaconda – path environment variable in windows
- Pandas: ValueError: cannot convert float NaN to integer
- How to find all occurrences of an element in a list
- convert json ipython notebook(.ipynb) to .py file
- how to update spyder on anaconda
- Django upgrading to 1.9 error “AppRegistryNotReady: Apps aren’t loaded yet.”
- Pygame Drawing a Rectangle
- Purpose of `numpy.log1p( )`?
- How do I change the figure size for a seaborn plot?
- How to use pyinstaller?
- Create a Pandas Dataframe by appending one row at a time
- ‘Pip’ is Not Recognized as an Internal or External Command windows 10 CMD
- Failed to load the native TensorFlow runtime – TensorFlow 2.1
- Using headers with the Python requests library’s get method
- pip install mysql-python fails with EnvironmentError: mysql_config not found
- How to extract the substring between two markers?
- How do I make a python script executable?
- How to truncate float values?
- How do I write a “tab” in Python?
- TypeError: ‘builtin_function_or_method’ object has no attribute ‘__getitem__’
- Proper use of mutexes in Python
- Euclidean Algorithm / GCD in Python
- Pandas split DataFrame by column value
- Using numpy to build an array of all combinations of two arrays
- Get a random sample with replacement
- Can’t update to numpy 1.13 with anaconda?
- Is there any simple way to benchmark Python script?
- Purpose of python antigravity module
- Error: “dictionary update sequence element #0 has length 1; 2 is required” on Django 1.4
- What is the Python equivalent of Matlab’s tic and toc functions?
- Flask-SQLalchemy update a row’s information
- Inline for loop
- Read data (.dat file) with Pandas
- Is there any numpy group by function?
- What is the correct format to write float value to file in Python
- How is Python’s List Implemented?
- ImportError: No module named IPython
- How to find length of digits in an integer?
- What exactly do “u” and “r” string flags do, and what are raw string literals?
- “E: Unable to locate package python3-pip”
- Eclipse, PyDev “Project interpreter not specified”
- ValueError: total size of new array must be unchanged
- Shuffle an array with python, randomize array item order with python
- Separating html and JavaScript in Flask [duplicate]
- No handlers could be found for logger