Python 2.7 [Errno 113] No route to host
I have 2 computers on the same LAN. The first PC has an ip address 192.168.178.30, the other PC has an ip address 192.168.178.26. Ping, traceroute, telnet, ssh, everything works between the two PCs. Both PCs run the same OS - CentOS 7 and both PCs have the same python version 2.7.5 (checked with the python -V command).
I copied simple python code from a computer networking book.
from socket import * serverName = '192.168.178.30' serverPort = 12000 clientSocket = socket(AF_INET, SOCK_STREAM) clientSocket.connect((serverName,serverPort)) sentence = raw_input('Input lowercase sentence: ') clientSocket.send(sentence) modifiedSentence = clientSocket.recv(1024) print 'From Server:', modifiedSentence clientSocket.close()
from socket import * serverPort = 12000 serverSocket = socket(AF_INET,SOCK_STREAM) serverSocket.bind(('192.168.178.30',serverPort)) serverSocket.listen(5) print 'The server is ready to receive' while 1: connectionSocket, addr = serverSocket.accept() sentence = connectionSocket.recv(1024) capitalizedSentence = sentence.upper() connectionSocket.send(capitalizedSentence) connectionSocket.close()
The code works when it is ran on the same PC (where the server is listening on localhost). When I run the client code on one PC and the server code on the other PC I get this error on the client side.
Traceback (most recent call last): File "client.py", line 5, in <module> clientSocket.connect((serverName,serverPort)) File "/usr/lib64/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 113] No route to host
Can someone help?
Check the firewall (on the server).
socket.error: [Errno 113] No route to host (Adding, OSError: [Errno 113] No route to host #1213. Closed. mkzia opened this issue on Sep 5, 2019 � 2 comments. Closed� This question relates to runtime network stack configuration (routing table correctness), not to software development. The same issues would impact any other tool, including end-user tools such as ping, telnet, etc; and are thus not on-topic here.
I stopped the firewall like Messa suggested and now it works.
service firewalld stop
I still don't understand what the problem was. I even tried using different distributions. Do all distributions have strict firewalls or something. For example Ubuntu to Ubuntu, Ubuntu to CentOS, CentOS to Ubuntu I still had the same problem (error).
OSError: [Errno 113] No route to host � Issue #1213 � jupyter , help with: OSError: [Errno 113] No route to host #576. Closed. renanfilipe opened this issue on Feb 2, 2018 � 5 comments self.session.port) File "/home/lonami/ Documents/Projects/Python/PyCharm/Telethon/telethon/network/connection.py", � Problem: error: [Errno 113] No route to host S3cmd: 1.6.1 python: 2.7.9 (default, Mar 8 2015, 00:52:26) [Errno 113] No route to host. Copy link Quote reply
bind the server socket to
help with: OSError: [Errno 113] No route to host � Issue #576 , Python rpyc “socket.error: [Errno 113] No route to host” gmail.com. I have two machines using python rpyc ,one is server (ip:10.0.3.120) , another is client(ip: 10.0.3.197). The code shows below: 2/26/14 Tomer Filiba. it's probably firewall � >> Python. >> >>> With timezone configured, it finds the server, but, when I try to [Errno 113] No route to host> On Tryton 2.8 it installs with no problem. Have
~]#supervisord Error: No config file found at default paths (/usr/etc/supervisord.conf, /usr/supervisord.conf, supervisord.conf, etc/supervisord.conf, /etc/supervisord.conf); use the -c option to specify a config file at a different path For help, use /usr/bin/supervisord -h
You should use
ln -s /etc/supervisor/supervisord.conf /usr/etc/supervisord.conf
Python rpyc “socket.error: [Errno 113] No route to host”, "No route to host" error running python console in a container Follow. Avatar Python 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5� When you’re trying to connect to a service on Linux, “No route to host” is one of the last things that you want to hear. It’s a broad message that means that your computer can’t reach the target server. Because of the broad nature of the message there are several possibilities that could be causing it. Related: How to Rename Files in
"No route to host" error running python console in a container – IDEs , SSH is the secure way of connecting to Linux servers and one of the common errors we see when using SSH is the "ssh: connect to host port 22: No route to host".
I had troubles getting the same results with python 3.6 and requests 2.18. I managed to get the errno using the http and socket modules : import socket, html try: http.client.HTTPConnection('invalid').connect() except (socket.gaierror, ConnectionError) as e: print(e.errno) Hopefully it helps someonelse.
I can connect to a container that uses this without any problems however when I open up the python console, which tries to run that remote interpreter, I get this: Python 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2 Traceback (most recent call last):
- Can you add the network configuration (
ip addr) of both machines to your question? This seems to be more of a network problem than one with the Python API.
- @ThePraetor: Did you just delete your comment on this answer? If disabling the firewall worked, I'd actually be curious on where you disabled it, because when it was the server firewall, I was obviously wrong in my other comment about the 'No route to host' message.
- I added an answer. Deleted my comment by mistake :(.
- While that's worth a try, it should also be possible to only bind to the specific LAN IP.
- Just tested it. Still the same error. Anyway, I think it should work even with 192.168.178.30.
- Yeah, actually if it was the listen part that would cause problems, the error would be something like 'Connection refused', same with the firewall mentioned in the next solution. 'No route to host' means that program can't even figure out to which device it should send the message, not that the receiving device won't accept the connection.