I start SqlServer Express that works on port 1433. Then I run a Java application that creates a server socket that executes a bind to the local ip and port 1433.I do not understand why it does not give an execution error. Can there be two applications working on the same port?

This is the java code:

public static void main(String[] args) throws IOException {ServerSocket sSocket=new ServerSocket();sSocket.bind(new InetSocketAddress("", 1433));}

Thank you

  • 2
    Maybe your SqlServer is running on (localhost) instead of– wernerFeb 14 at 21:08

Your operating system handles the sockets and knows if it was set for internal use with the IP or external use with A double binding of one socket with the same IP and Port is not possible. A IP will listen to all sources internal or external (all IP'S) on a given port.

P.S. Try to use new Socket(IP, PORT).

  • No. Explicitly binding to the external interface, does not bind to localhost.– Thorbjørn Ravn AndersenFeb 14 at 21:17
  • sry, I wasn't precise enough and changed it.– Alexander M.Feb 14 at 21:21
  • Sorry, but I don't understand it. I've changed the ip to to listen all the interfaces but it works...with sql server express running. Could be Sql server listening other port? How can I now it?– Alberto Feb 14 at 21:26
  • First go to your Task Manager and search for the Process ID (PID) of your SQL server in the details tab. if you are on windows go to console and type: netstat -aon here you can find all bound sockets and there PID's– Alexander M.Feb 14 at 21:32
  • What on earth does your PS mean? An InetSocketAddress isn't a binding at all, let alone an external binding, and Sockets don't 'bind to all'.– user207421Feb 14 at 21:38

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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