[GLASSFISH-16344] Unable to start two domains on system where IPs are aliased to the same network interface. Created: 12/Apr/11  Updated: 18/Feb/13  Resolved: 18/Feb/13

Status: Closed
Project: glassfish
Component/s: admin
Affects Version/s: 3.1
Fix Version/s: 4.0

Type: Bug Priority: Major
Reporter: Ryan Lubke Assignee: Byron Nevins
Resolution: Works as designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags: 3_1_1-exclude, 3_1_1-scrubbed, 3_1_x-exclude


I'm trying to start two different domains on the same system, but have
run into some issues that I hope you may be able to help with.

Firstly, the machine I'm working with has a single NIC. The IP address
is I've created an IP alias to this NIC,

With a simple perl script, I'm able to bind the same port on either
address (i.e. bind a server on and

So, this confirms I have a basic working configuration.

Now, I create a second domain, domain2, and update all the appropriate
addresses to refer to I update domain1 in a similar
fashion and set the addresses to

I start domain1 using the following:

asadmin --host start-domain --verbose domain1

I can see in the log that is being used as expected.
However, when I attempt to start domain2 using:

asadmin --host start-domain --verbose domain2

I receive the following error:

There is a process already using the admin port 4848 – it
probably is another instance of a GlassFish server.

I've looked through the code and came across this:

private static boolean isPortFreeServer(int port) {
// check 3 different ip-port combinations.
// Amazingly I have seen all 3 possibilities – so just
checking on
// is not good enough.
// Usually it is the – but JMS (default:7676)
// only returns false from the "localhost":port combination.
// We want to be aggressively disqualifying ports rather than
the other
// way around

try {
byte[] allZero = new byte[]

{0, 0, 0, 0}

InetAddress add = InetAddress.getByAddress(allZero);

if (isPortFreeServer(port, add) == false)
return false; // return immediately on "not-free"

add = InetAddress.getLocalHost();

if (isPortFreeServer(port, add) == false)
return false; // return immediately on "not-free"

add = InetAddress.getByName("localhost");

return isPortFreeServer(port, add);
catch (Exception e)

{ // If we can't get an IP address then we can't check return false; }


which is invoked by StartServerHelper to ensure the port isn't already

In my environment, the second isPortFreeServer() fails as
InetAddress.getLocalHost() in this
case returns While this return value is correct, this
appears to be a false positive.

Wouldn't it make sense, in the case when an explicit host and/or port is passed to asadmin
to perform the validation against those arguments instead of against the local addresses?

Comment by Byron Nevins [ 24/May/11 ]

Setting target to 3.2


Can you give me a simple way to reproduce this on my windows machine – i.e. step-by-step cookbook?

Comment by Ryan Lubke [ 24/May/11 ]

Unfortunately, I don't have easy access to a win32 environment so I can't tell you how to alias the IP.

The steps outside of the ip aliasing are there in the bug report.

Comment by Byron Nevins [ 18/Feb/13 ]

We have so many possible combinations and installations of networking. The current code is the result of years of testing and tweaking.

It is too dangerous to change this area of code for a very very rare situation.

Final solution: Don't do that!

Generated at Fri Aug 28 14:43:08 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.