Can't access localhost via IP address

后端 未结 2 798
情歌与酒
情歌与酒 2021-02-07 01:09

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/

相关标签:
2条回答
  • 2021-02-07 01:38

    If you are using Python 3.8, this is a known bug. The solution is to manually specify the IP address with the -bind argument or use Python 3.9.

    python -m http.server 8000 --bind 127.0.0.1 (or 0.0.0.0, <insert-your-ip-here>)

    0 讨论(0)
  • 2021-02-07 01:40

    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.

    0 讨论(0)
提交回复
热议问题