How to Solve Error: socket.gaierror: [Errno 8] nodename nor servname provided, or not known
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
hostname is not written in /etc/hosts. For example, the MAC-20150101 in the abnormal information above is actually the host name of our Mac system. Some codes may need to find the corresponding IP address in the local DNS according to the host name, because the local DNS configuration is not specified What is the IP address of the host name, this error will also be prompted.
Implement in python interpreter:
Call the gethostname() method provided by the Socket library to obtain the host name
>>>import socket >>>socket.gethostname() >>>>exit()
Get the host name, modify the hosts file, enter the command
Add the host name 127.0.0.1 hostname
The solution to prompt nodename nor servname provided when the Java Web project is started on the Mac system
java.net.UnknownHostException: MAC-20150101: MAC-20150101: nodename nor servname provided, or not known at java.net.InetAddress.getLocalHost(InetAddress.java:1473) at org.eclipse.rse.core.RSECorePlugin.getLocalMachineName(RSECorePlugin.java:265) at org.eclipse.rse.core.RSEPreferencesManager.getDefaultPrivateSystemProfileName(RSEPreferencesManager.java:358) at org.eclipse.rse.core.RSEPreferencesManager.initDefaults(RSEPreferencesManager.java:337) at org.eclipse.rse.internal.core.RSEPreferenceInitializer.initializeDefaultPreferences(RSEPreferenceInitializer.java:23) at org.eclipse.core.internal.preferences.PreferenceServiceRegistryHelper$1.run(PreferenceServiceRegistryHelper.java:300) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) .... .... .... Caused by: java.net.UnknownHostException: MAC-20150101: nodename nor servname provided, or not known at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293) at java.net.InetAddress.getLocalHost(InetAddress.java:1469) ... 28 more
Regarding the MAC-20150101 in the exception information, it is actually the host name of our Mac system. Some codes may need to find the corresponding IP address in the local DNS according to the host name, because the local DNS configuration does not specify the host What is the name of this IP address, this error will also be prompted.
The solution is very simple:
1) Open the terminal on the Mac system, check the current host DNS configuration, enter the command cat /private/etc/hosts, as shown in the figure:
2) Then edit the host configuration, add the mapping of the host name, enter the command sudo vi /private/etc/hosts, enter the VI editor, and add the following mapping
Just exit and save.
3) Finally, enter the refresh command dscacheutil -flushcache in the terminal
After three steps, when starting the Java Web project, the following error message will not appear.
The reason for this error is that the Internet says that there is a place in the project that calls the following code:
It is said that this method will return FQDN (Fully Qualified Domain Name), if the host name is not configured, then calling this code will throw an exception message, and this method depends on the underlying operating system, the configuration of the Mac system is somewhat different from that of Windows !
Socket.gaierror: [Errno -2] Name or service not known error solution when configuring the remote server Jupyter notebook
Modify the jupyter_notebook_config.py configuration file and enter the command:
In the configuration file, search for c.NotebookApp.ip, find this sentence and modify it to c.NotebookApp.ip=’0.0.0.0′ (general tutorial will write and modify it to’*’), save and restart the notebook.
## The IP address the notebook server will listen on. c.NotebookApp.ip = '*' c.NotebookApp.allow_remote_access=True
- [Errno 8] nodename nor servname provided, or not known
- [Solved] org.mongodb.driver.cluster – Exception in monitor thread while connecting to server node1:27017
- TIP: Unable to initialize gtk, is DISPLAY set properly?
- Start Eclipse and pop up the “Failed to load the JNI shared library jvm.dll” dialog box
- Modify the default file location of the Jupiter notebook
- Exception: jupyter command Jupiter notebook not found
- The solution to the problem that the virtual machine and the host SSH can’t connect on vmvare
- Ubuntu 16.04 modify jupyter default path
- Idea for Mac setting JVM running parameters to solve running stuck problem
- The solution of a Java exception has occurred. And error exception in thread when eclipse runs
- socket.error : [errno 10048] and view PID process number and port number
- Elasticsearch startup process error: org.elasticsearch.transport .BindTransportException: Failed to bind to [9300-9400
- BO error Error: RWI 00200 FWM 01014
- How to solve the SNMP error of cacti
- Someone is doing something abnormal
- Sudo: unable to resolve host solution
- TNS-12545: Connect failed because target host or object does not exist
- A solution to the refusal of rdesktop connection to windows host
- Version 1.8.0_201 of the JVM is not suitable for this product. Version: 11 or greater is required.
- Eclipse startup error: a Java runtime environment (JRE) or Java Development Kit (JDK) must be available