I've built an application that listens on the localhost address and a specific port, lets say port 11001. Its on a remote machine with CentOS. I currently have a python script on my local machine that I'm using to communicate with the application.

I've never been able to connect to the application from my local machine. I've tried using netstat, nc, etc to no avail. I've tried to connect from other machines. I can successfully ping the remote machine from my local machine and the others I've tried to connect from but I'm unable to reach my application. I'm pretty sure the IP and port number I'm connecting to is the one that the remote application uses.

Here's the error I'm getting from the python script:

error: [Errno 10060] A connection attempt failed because the connected
party did not properly respond after a period of time, or established 
connection failed because connected host has failed to respond

I'm also able to SSH into the server but not able to connect to the remote application. I can only assume that I need to do some sort of configuring on the machine for the application.

How do I allow remote connections to the my custom application?

EDIT: The problem was iptables. I just had to configure the iptables to accept requests from the port.

  • 1
    If it's only listening to localhost, you'll never be able to connect to it from a different host. It needs to listen on the external interface. – John Dec 30 '15 at 15:32
  • Okay I'm a bit confused. If I have an application listening on localhost, doesn't it mean that I can connect to it using the address of the machine? I've been using scripts that listen on localhost and I'm able to connect to them using the IP address of the machine its hosted on. – Anfernee Dec 30 '15 at 15:35
  • Then those applications are listening on the external interface as well. If you listen only on (localhost), you can only connect to whatever is listening from that machine itself. – John Dec 30 '15 at 15:37
  • Can you post the output of netstat -tuln and iptables -L on the machine the service is listening on? – John Dec 30 '15 at 15:38
  • 1
    Ok, so you're not listening on localhost, you're listening on, which is "all interfaces". So far, so good. I suspect the issue is with the host firewall, which is why I asked for the iptables output. – John Dec 30 '15 at 15:44

Configuring iptables was the trick. I just added a rule at the top of the configuration file to accept incoming connections on port 11001 and the application started receiving requests.

I used the two following links for help:



First try to connect to the application on the same host where the application is running , if it works , then make the application listen on some port with ip address , let's say , then access this from your remote client (on the same LAN), and you may also need to disable firewall/iptables during testing on the server or just allow the port you want to access.Also disable the firewall on the client.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.