Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
758 views
in Technique[技术] by (71.8m points)

networking - Can't access localhost via IP address

I'm viewing a locally hosted website (using grunt serve, if that matters). I can view it via http://localhost:9000/ or http://127.0.0.1:9000/, but not via http://10.0.0.16:9000/.

10.0.0.16 is my local IP address (from ifconfig or System Preferences), but I cannot access my locally hosted content at http://10.0.0.16:9000/ from either the device that is hosting it or from other devices on the network.

I haven't had trouble using my local IP address to access locally hosted sites when my computer is on other networks, only on my home network. Do you have any idea what needs to change?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you can access a server running on your own machine via 127.0.0.1 (or localhost) but not via the computer's ip address, this means that the server software is configured to listen on the localhost interface only. This is a configuration item and to avoid exposing a potentially unsecure server many server programs come preconfigured to listen on localhost only. That way you can safely test locally before exposing the server.

Note that 0.0.0.0 means "listen on all interfaces present on this computer" which is convenient, but may cause security issues if the machine has multiple interfaces.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...