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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:32:15+00:00 2026-06-03T03:32:15+00:00

One of our Java program when started, it only listen on IPv6 (8080) e.g.

  • 0

One of our Java program when started, it only listen on IPv6 (8080)

e.g.

# netstat -ntpl

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -               
tcp6       0      0 :::8080                 :::*                    LISTEN      -               
tcp6       0      0 :::22                   :::*                    LISTEN      -               

The problem is it is not accessible from outside (except localhost), to solve this, I have this manually add

-Djava.net.preferIPv4Stack=true

But this make the program is only for IPv4 network.

Is it possible to do something like the sshd as above, both support IPv4 and IPv6?

  • 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-06-03T03:32:17+00:00Added an answer on June 3, 2026 at 3:32 am

    I suspect it’s less a Java programming issue than an OS networking stack/OS network configuration issue:

    http://coding.derkeiler.com/Archive/Java/comp.lang.java.help/2009-09/msg00087.html

    On some OSes, a single native TCP socket can listen to a port on both
    IPv4 and IPv6 simultaneously. It is able to accept connections from
    remote IPv4 and from remote IPv6 clients. On other OSes (such as WinXP)
    an OS native socket CANNOT do that, but can only accept from IPv4 or
    IPv6, not both. On those OSes, it is necessary to have two listen
    sockets in order to be able to accept connections from both remote IPv4
    and IPv6 clients, one socket to listen for IPv4 connections and one for
    IPv6.

    Windows 7 and Windows Server 2008 handle dual stacks just fine; Windows XP not so much 🙂

    You seem to be on Linux – most modern Linux desktops and servers also handle dual ipv4 ipv6 with no problem.

    Here’s a good article on interoperability:

    • http://ntrg.cs.tcd.ie/undergrad/4ba2.02/ipv6/interop.html

    You know how you can “turn off” IPV6 for your Java application: -Djava.net.preferIPv4Stack=true

    You can also force your server to use IPV6 like this: echo 0 > /proc/sys/net/ipv6/bindv6only

    This is arguably your best source:

    • http://docs.oracle.com/javase/6/docs/technotes/guides/net/ipv6_guide/index.html

    You should absolutely be able to accomplish what you want (at least at the Java programming level), unless you’re limited by external network issues:

    Nodes)      V4 Only  V4/V6  V6 Only
                -------  -----  -------
    V4 Only     x        x   
    V4/V6       x        x      x
    V6 Only              x      x
    

    PS:

    Here’s one more good link, which explains what’s happening at the socket level. It’s not Java (it’s C), but exactly the sample principles apply:

    • Accept connections from both IPv6 and IPv4 clients
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On one of our Java application screens, we want to display data loaded from
Ok, I got one of our JAVA/JDBC guys to come take a look at
One of the memory leaks I've discovered in our application is the java.awt.Window.allWindows private
One of our MSI's has started failing with Error 2902. It'll get most of
In Java, while using Glassfish Server, we could only save files relative to our
One of our Java project needs a redundant data store system which is highly
We have a URL object in one of our Java classes that we want
I'm trying to catch a memory leak in one of our Java daemons, and
A customer got this Java security warning on one of our ancient java components
One day our java web application goes up to 100% CPU usage. A restart

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.