简体   繁体   中英

How to make react-native use the hosts file in Mac OS X El Capitan?

I've added a new entry in my /etc/hosts file and its not reflecting in the IOS Simulator. I'm using OS X El Capitan. This is my hosts file

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost

192.168.10.10   homestead.app

I can access homestead.app from the simulator's Safari web browser but I cannot access from my react-native app. I have tried restarting simulator, restarting Mac, resetting the simulator settings but it's not working.

The Simulator is a separate userspace running on the host macOS kernel. All networking is handled by the kernel, so there is nothing special about the Simulator per-se. If Safari in the Simulator can resolve the host then it is working. The problem may be somewhere in your app, the app transport policy blocking a non-SSL connection, or if you are serving with a self-generated cert it could be a trust issue.

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