Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6912793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:08:10+00:00 2026-05-27T09:08:10+00:00

I am trying to tcp connect to a server machine in java, by using

  • 0

I am trying to tcp connect to a server machine in java, by using its public i.p. but when i run the client application i constantly getting a connection refused error. if i used localhost instead of the public ip, it works perfectly.

i search the internet for several causes of the issue but i couldnt fix it.

i forwarded the port to my machines’ local i.p address(192.168.1.3) in routers settings. then i checked if port is listening when i ran the server application using netstat -an. i saw lines like,
0.0.0.0:19999 or []:19999 .
19999 is the port number i am trying to listen to. Then i changed my ServerSocket constructor to the 3 parameter one, which also binds the local address.

InetAddress miad = InetAddress.getByAddress(addr);
ServerSocket socket1 = new ServerSocket(port,10,miad);

addr is the InetAddress of my machines local i.p. After these modifications, when i start the server application, i run netstat and it shows:

TCP   192.168.1.3:19999    0.0.0.0 LISTENING

Here i think that my server is listening on the port specified properly.

I have also disabled my firewall and antivirus software.

I have seen several threads and discussions on the net about the issue, and tried most of the things mentioned there, but i keep getting the connection refused error.

What can i be doing wrong? It runs without any errors when i test with localhost.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:08:11+00:00Added an answer on May 27, 2026 at 9:08 am

    This is because of the router (not very sure, but almost). Try to see if a webservice like http://www.canyouseeme.org can connect to your server.

    The main idea is that an internal machine (inside the LAN) cannot connect to a machine inside the same LAN by using the external (public) IP address.

    I’m pretty sure that it will work, using you internal ip (192.168.1.3).

    And if you are sure that you forwarded ports correctly, CanYouSeeMe will say your server is reachable. If it doesn’t, make sure you ISP isn’t blocking the ports for some kind of “safety reasons”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to connect to a standalone desktop tcp server(java) from tcp client
I have TCP client application and trying to connect with Server located at remote
I am trying to connect the Sql Server 2008 R2 with java using JDBC.I
I am trying to create a simple client/server application using Thrift which is going
I am trying to open up a TCP socket in my client application so
I am trying to connect an iOS device with a server trough TCP. I
i am trying to connect to a server on my network running a tcp
hy again! I'm trying to connect two emulators running as server and client on
I am getting error when trying to run Python socket http server. import SocketServer
I have client and server programs which now communicate via TCP. I'm trying out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.