简体   繁体   中英

I can reach from browser “http://localhost:8080/” but not “my_private_ip:8080/”

I am in my homework LAN, the private IP of my Macintosh (Mac OS X El Capitan 10.11.4) is 192.168.1.9 and my Firewall is OFF. I have run a wildfly 10 web project on " http://localhost:8080/ " until I access to that project from the localhost everything works fine, when I try to reach it from http://192.168.1.9:8080/ google chrome tell me:

This site can’t be reached
192.168.1.9 refused to connect.
Search Google for 192 168 8080
ERR_CONNECTION_REFUSED

I need to access it from an external mobile device but if I can not even access it from my own computer from the IP of the computer itself it's hard to thing to pass to the mobile device...

The strange thing is that I also have MAMP Apache port listening on port 80, and in fact both " http://localhost/ " and " http://192.168.1.9/ " works perfectly fine (showing me the defaul MAMP "www/index.php").

Configure from eclipse

If you want to set the IP from eclipse you should follow these steps (changing the IP in the file standalone.xml doesn't work from eclipse because of the -b option which is set, see more below...)

This are the steps to configure it on eclipse:

  1. Click on your Wildfly Server Wildfly服务器
  2. Click on Open Launch Configuration Wildfly服务器配置 Uncheck the Always update arguments related to the runtime and then change your -b option with your_private_ip (if you remove the option, -b localhost you could configure it directly from the standalone.xml file, see the section below for configuring it) 编辑Wildfly服务器配置
  3. Or simply, instead of the 2. solution, check the box Listen on all interfaces to allow remote web connections

Configure from standalone.xml

An alternative is configure in standalone.xml the interfaces section.

Change:

<interfaces>
  <interface name="management">
   <inet-address value="127.0.0.1"/>
  </interface>
  <interface name="public">
   <inet-address value="127.0.0.1"/>
  </interface>
</interfaces>

to:

<interfaces>
  <interface name="management">
   <!-- Use the IPv4 wildcard address -->
   <any-ipv4-address/>
  </interface>
  <interface name="public">
   <!-- Use the IPv4 wildcard address -->
   <any-ipv4-address/>
  </interface>
</interfaces>

Or simply replace 127.0.0.1 with your private IP


Configure from command line (running the server from command line)

Another alternative is running it directly from command line. By default jboss/wildfly binding to localhost, if you want change this, you can execute:

standalone.sh -b 0.0.0.0

listen on all IP addresses of the machine (if multihomed)

or if you want to listen on your ip:

standalone.sh -b your_private_ip

Ref:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM