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 6756175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:29:35+00:00 2026-05-26T13:29:35+00:00

Is anyone having issues with Java’s InetAddress.getLocalHost() resolution in Java with OSX Lion when

  • 0

Is anyone having issues with Java’s InetAddress.getLocalHost() resolution in Java with OSX Lion when working offline (i.e. not connected to internet)?

It would appear that localhost:127.0.0.1 is not resolved at all:

Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
    at java.net.InetAddress.getLocalHost(InetAddress.java:1356)

Nothing special in my /etc/hosts:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0     localhost

I suspect this is not a Java issue, but rather an OSX Lion DNS resolution issue.

Can anyone help?

If this is not the right forum, where can I ask about this?

Any tips on how debug this further at OSX level?

UPDATE 26/10/2011 – This could be JDK bug, the following test:

InetAddress addr;
try {
   addr = InetAddress.getLocalHost();
   System.out.println("With localhost access: " + addr);
} catch (ArrayIndexOutOfBoundsException e) {
   addr = InetAddress.getByName(null);
   System.out.println("With reverse lookup: " + addr);
}

Would print the following when offline:

With reverse lookup: localhost/127.0.0.1

Cheers,
Galder

  • 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-26T13:29:36+00:00Added an answer on May 26, 2026 at 1:29 pm

    Found a way to workaround this issue, just add an alias for localhost to the network interface:

    sudo ifconfig en0 alias 127.0.0.1
    

    Once that’s in place, I get no localhost issues any more when offline.

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

Sidebar

Related Questions

Is anyone having experience working with pycassa I have a doubt with it. How
I’ve been having issues with a Java File. It's designed to write line after
Hey everyone, I'm working on a hex dump utility made in Java. I'm having
I am having issues with regex always returning false even though http://developer.android.com/reference/java/util/regex/Pattern.html states it
I was wondering if there's anyone having an idea how to tackle with the
Is anyone else having trouble running Swing applications from IntelliJ IDEA 8 Milestone 1?
I'm having the following problem and wondered whether anyone could see why this is
Can anyone help with an odd Ruby Gem problem I'm having - note I've
I'm having some trouble getting jQuery to play nice with DokuWiki - has anyone
Can anyone recommend a free grid/graphing component for C#/.NET? I'm having a look at

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.