Access localhost ( running on Mac OS X ) from another machine in the network

1

1

I have a REST service running on Mac OS X, which im currently accessing using "localhost:8888" and "10.0.2.2:8888"

I want to access the same service from another computer which is in the same network.

I disabled the firewall also and I typed

 nc -v 192.168.1.3 8888

and got the result as

nc: connectx to 192.168.1.3 port 8888 (tcp) failed: Connection refused

currently i use localhost (to access using java application) and 10.0.2.2 (to access using android application runs in the simulator) which both runs on the same machine which the server runs too.

I want to put the android application to my phone and give the machine ip addess ( because if i connect to internet via wifi, it'll be in the same local area network) i should be able to access my service runs on my machine.

can some one please tell me what im doing wrong here? Thank you

Ramindu De Silva

Posted 2015-01-16T19:48:25.510

Reputation: 11

what is the IP address of the machine running your webserver? (run ifconfig from the command line if you aren't sure). – Catherine MacInnes – 2015-01-16T22:02:29.907

its 192.168.1.3 – Ramindu De Silva – 2015-01-17T02:15:13.210

You'll need to configure your "server" to listen on all IPs. E.g. if Apache is configured to listen to 127.0.0.1:80 then that is all it will respond to (localhost). Your server may have a configruation to change to, say, 0.0.0.0:<port> or :<port> to imply everything. You should also consider looking at any firewall rules. – Kinnectus – 2019-02-20T12:32:28.817

Answers

-1

Type 192.168.1.3:8888/rest/getDetails on other computer. Replace rest and getDetails with your request mappings. You do not even need to fiddle with firewall. I am running a Restful app in Java on Mac and able to access on other networked computers.

Pratik

Posted 2015-01-16T19:48:25.510

Reputation: 121

-1 because this answer is just "it works for me". – gronostaj – 2019-02-20T12:17:36.927