• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Trying to edit hosts file on Bluestacks 5 but can't get adb working...

Hi

I'm not an Android developer by any stretch of the imagination so please bear with me if I'm a little slow on this, but I'm trying to add an entry to the hosts file in Bluestacks 5 (on Windows 10) and I'm not getting very far.

I've rooted it (confirmed with Root Checker) and have downloaded a terminal emulator, but every time I try and edit the hosts file, it just says "hosts is read-only" when I come to save it.

From looking round online, some suggestions are that the filesystem is mounted in read-only mode and needs to be mounted in read-write mode. I found this post that provides what seems to be a decent set of steps and mentions the use of adb. So I've downloaded platform tools from here and unzipped to the PC on which Bluestacks is running (btw I don't have the full Android Studio installed).

The first thing I ran was:
Code:
adb devices

...and it threw an error:
Code:
adb server version (36) doesn't match this client (41); killing...
* daemon started successfully
List of devices attached

However, if I now run the same command again, it no longer throws this error...so I don't know if that's an issue or not?

I've checked in Bluestacks settings and the "Android Debug Bridge" option is enabled and is on 127.0.0.1:52337.

I then tried to connect to this using:
Code:
adb connect localhost:52337

...and it came back with:
Code:
cannot connect to 127.0.0.1:52337: No connection could be made because the target machine actively refused it. (10061)

Can anyone help with this? Or am I totally barking up the wrong tree? And if so, is there a better way of editing the hosts file?

Thanks
 
Can anyone help with this? Or am I totally barking up the wrong tree? And if so, is there a better way of editing the hosts file?

Thanks

I don't think you can edit the hosts-file in Bluestacks. Because as I understand with Bluestacks, the virtual Android system it boots is embedded in the main executable file that Windows(the host OS) runs, and so the all the system files in the virtual Android system will be read-only. And the only thing that is read/write is the virtual drive that Bluestacks creates when it's installed, which appears as user Internal Storage to the apps running in the Android virtual machine.

However I think you could edit the Windows hosts-file, because whatever you change in the host OS hosts-file would also change the virtual OS internet access, like for blocking certain websites.
 
Last edited:
I don't think you can edit the hosts-file in Bluestacks. Because as I understand with Bluestacks, the virtual Android system it boots is embedded in the main executable file that Windows(the host OS) runs, and so the all the system files in the virtual Android system will be read-only. And the only thing that is read/write is the virtual drive that Bluestacks creates when it's installed, which appears as user Internal Storage to the apps running in the Android virtual machine.

However I think you could edit the Windows hosts-file, because whatever you change in the host OS hosts-file would also change the virtual OS internet access, like for blocking certain websites.

Thanks mikedt - I did wonder if Bluestacks would just pick up whatever was setup on the Windows host machine, but it appears that isn't the case when it comes to hosts. The hosts file in Windows contains the entry I need, and I can access it fine from Windows, but I am unable to access it from within Bluestacks
 
Thanks mikedt - I did wonder if Bluestacks would just pick up whatever was setup on the Windows host machine, but it appears that isn't the case when it comes to hosts. The hosts file in Windows contains the entry I need, and I can access it fine from Windows, but I am unable to access it from within Bluestacks

You can use the Root Explorer app to edit your hosts as long as your BlueStacks is rooted correctly everything should run smoothly.
 
Back
Top Bottom