Question

cannot connect to a port

My droplet has debian os. I have a java application running which tries to exchange data with remote similar applications. This data exchange has previously worked across remote environments where each node has been a hardware node. It uses apache tribes package to exchange peer to peer messages over TCP.

I have set TCP port 4000 as a rule in my firewall and I have been expecting to be able to communicate with my application listening on that port. Netstat reports 4000 to be a listening port.

In the past with my application running on a dedicated remote server, I have been able to connect using telnet from a remote system (in which case my log files respond reporting junk data). Currently, telnet reports “?need to be connected first”

Also, from the droplet command line I issue: echo “some text” > /dev/tcp/127.0.0.1/4000 which invokes “connection refused”

If I use udp instead, there is no error, but still no indication that the data reached my application.

many thanks,

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
January 1, 2020
Accepted Answer

Hello,

It sounds like that your Java app is binding to 127.0.0.1:4000 rather than 0.0.0.0:4000 so that’s why you can only access it locally from the server itself.

To check if this is true you can run:

netstat -plant | grep 4000

If you get something like this:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:4000          0.0.0.0:*               LISTEN      27944/java  

Then you would need to change your application so it binds to 0.0.0.0 rather than 127.0.0.1, that way you would be able to access it remotely.

Let me know how it goes! Regards, Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more