Access to homestead host from genymotion - vagrant

How can i access homestead from genymotion emulator ?
i add this line into emulator hosts file, but not work :
192.168.10.10 myapp.app

Here's how I did it on Windows 10:
Check if homestead works
My homestead is running on the ip 192.168.10.10 and has multiple sites. Each have been added to my Windows machine's hosts file to be available from specific domains.
For example in my C:\Windows\System32\drivers\etc\hosts file i have added the following lines:
192.168.10.10 app1.dev
192.168.10.10 app2.dev
This means when browsing http://app1.dev in my Windows machine it should be showing my site. If this is not working for you, then check homestead's official docs how to do this properly. The setup will vary on the version of homestead you are using.
Configure adb for Genymotion
I have Android SDK installed and setup on my Windows machine. You need to configure Genymotion for adb to work from the Windows command line. In Genymotion go to Settings > ADB > Use custom Android SDK tools and browse to your Windows machine's Android SDK directory. For me it was C:/dev/tools/android
Edit emulator devices hosts file
As the emulator is accessing the same network as your Windows machine, then your homestead's ip will also be available from the emulator. Thus you can add the same lines as you added in your Windows machine's hosts file.
1.Open the commandline and run the following commands to edit the hosts file:
adb root
adb remount
adb pull /system/etc/hosts hosts
2.The hosts file should now be present in the folder where you excecuted the pull command. Edit the file with a text editor and add the sites you want to access. For example i added:
192.168.10.10 app1.dev
192.168.10.10 app2.dev
3.Send the hosts file back to the emulator
adb push hosts /system/etc/hosts
4.Browse to your site in the emulator browser. For example: http://app1.dev You should see your homestead site now!
What to try if site is not reached from browser
1.Check that you added an empty line after the last site in the hosts file.
2.Close and reopen the emulator browser
3.Restart the emulator

Homestead runs using virtual box [or vmware] .I have used oracle virtual box .Just to be clear ,it's ubuntu os running on virtual box .So ipv4 of ethernet adapter for virtualbox host only network will work for you .On windows,
open "cmd" and run :
ipconfig
and search for "Ethernet adapter VirtualBox Host-Only Network"
and then ipv4 pest the ip with port no [8000 default],on your emulator's browser .In my case it's.
192.168.56.1:8000
Note: please check if your homestead environment working properly.
My genyotion version is : 2.5.4.
I think you have solved the problem but it may help others, Thank you.

Related

Use a domain like name to access a test site instead of an IP address

I'm currently testing a few websites on Ubuntu Server installed on Oracle VM Virtual Box on a Windows 11 machine.
I need to type an IP address to access these sites (eg: 192.168.xxx.xxx).
Is it possible to use something like a domain name to access them instead of using an IP address? Like mysite1.com, mysite2.com etc.
I'm not using domain names booked on godaddy or some place like that. Just names for local testing. How can it be done in this scenario? Everything is installed on the same machine.
Add your sites to /etc/hosts file like this:
192.168.... mysite.domain
Yes, you can go to /etc/hosts and apply IP you are using and the domain name you want:
Example.
Open with:
sudo nano /etc/hosts
apply:
192.168.x.x mysite.com
And restart server.
TRY CLEAN CACHE
sudo apt-get install nscd
AND NOW
sudo service nscd restart
or
sudo service dns-clean
To restate your setup, you have one Ubuntu server guest VM (in VirtualBox) running on Windows 11. Because you mentioned the 192.168.x.x IP range I will assume the guest VM is on a "bridged" vbox network adapter that any device on your local network can ping. I also have to assume the IP address(es) you are using are successfully connecting you from your Windows 11 host to your Ubuntu guest. Is all this correct? Does your VM have a desktop and a web application that can reach popular sites on the internet? Does the Ubuntu OS use DHCP or a static IP assignment?
The short answer is yes, you can use domain names instead of IP addresses. If you are not successful connecting to the IP address, switching to domain names will not help you. You have to have all the network dependencies satisfied first.
To choose a domain name for testing;
You should take a look at RFC 6761. Specifically at secion 6; 6.1 - 6.5
https://www.rfc-editor.org/rfc/rfc6761.html
.in-addr.arpa.
10.in-addr.arpa. 21.172.in-addr.arpa. 26.172.in-addr.arpa.
16.172.in-addr.arpa. 22.172.in-addr.arpa. 27.172.in-addr.arpa.
17.172.in-addr.arpa. 30.172.in-addr.arpa. 28.172.in-addr.arpa.
18.172.in-addr.arpa. 23.172.in-addr.arpa. 29.172.in-addr.arpa.
19.172.in-addr.arpa. 24.172.in-addr.arpa. 31.172.in-addr.arpa.
20.172.in-addr.arpa. 25.172.in-addr.arpa. 168.192.in-addr.arpa.
.test.
.localhost.
.invalid.
.example.com.
.example.net.
.example.org.
You may have to create/modify the \windows\system32\drivers\etc\hosts file that Windows uses to intercept asking DNS for IP/host mapping. If you are using a linux/unix client, the /etc/nsswitch.conf AND /etc/hosts files could override DNS for you. This may or may not be in the same location on Windows 11 but as of Windows 10 21H2 it was still there.

create react app On Your Network with WSL2 not working

I am trying to use a mobile device to view the app served by create react app. When I open the IP:PORT recommended by CRA's "On Your Network", the page never loads on my mobile device.
I am working on Windows 10 laptop, using WSL2 with Ubuntu. My network is all wifi, no ethernet cables. My code is on the Ubuntu file system and I run npm start from the same location in a WSL terminal from VS Code with the WSL extension.
I am able to see the app using http://localhost:3000 with browsers on my Windows machine (Chrome, Edge).
I noticed cmd.exe ipconfig lists the IP address that corresponds to "On Your Network" as "Ethernet adapter vEthernet (WSL)". This IP address (172.17.144.244) is different than what ipconfig shows as "Wireless LAN adapter Wi-Fi" (192.168.1.23). I also tried 192.168.1.23:3000 on my mobile device, but it didn't work either.
Some other posts on SO recommend removing a firewall setting that blocks NodeJS applications. I scrolled through the many applications listed in the firewall settings and found nothing for NodeJS apps.
Since WSL2 uses a virtual NIC what you need is enable port forwarding in the Firewall otherwise your server in WSL2 won't be seen by external PCs in your network.
I recommend reading the entire thread but in resume you can start using this script:
https://github.com/microsoft/WSL/issues/4150#issuecomment-504209723
I had the same issue. So instead of trying to restart the Windows, try to open the Powershell terminal, shut down the WSL, and then start it again. it solves to me.
Command to shut down: wsl --shutdown
Command to start: to start: wsl
Source: https://github.com/microsoft/WSL/issues/4885#issuecomment-803881561
I found a tool that fixes this problem: https://github.com/icflorescu/expose-wsl
First you need to run the command in the wsl terminal
npx expose-wsl#latest
and it gives you an ip address of your pc 192.168.0.130 for example, with that ip you can access the project from devices on the same network.
When running npm start:
.
.
.
On Your Network: http://172.48.228.88:3000
enter on mobile device:
http://192.168.0.130:3000
and works.
Note: You have to allow the port through the Windows firewall. In my case the firewall should allow access to 'C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.3.0_x64__...\wslhost.exe'
You can run your app in Docker instead and use Docker for Windows, enabled for WSL2. It somehow manages dynamic dynamically forward the ports, without having you to change anything in Windows.
I was also having the problem with hot reloading in WSL2 . I tried almost every solution present on github , stackoverflow and where not , from CHOKIDAR_USEPOLLING=true to setting FAST_REFRESH= false in .env file to changing network setting using netsh.... but none of them worked for me and after 2 days of searching solutions and trying to fix it .. finally reverted to wsl 1.
Just run this command on Powershell for now.
wsl --set-version Ubuntu-20.04 1
Consider Nginx for Windows.
I prefer this solution because I'm more familiar configuring web servers and reverse proxies than Windows networking and Powershell.
After unzipping the distribution, for example at C:\somepath\nginx-1.22.1, I add the following reverse proxy configuration to C:\somepath\nginx-1.22.1\conf\nginx.conf
...
http {
...
server {
listen 11500;
server_name wsl2_server;
charset utf-8;
location / {
proxy_pass http://localhost:11500/;
}
}
...
As you can see, I have a web server running on port 11500 in WSL2. When my mobile device requests "lan_ip_of_laptop:11500/", it then forwards to localhost:11500 and WSL2 server completes the request.

How to use Windows hosts file to access my website url from another laptop or system

I have done a project using Netbeans 8.2, Apache Tomcat 8, MySQL database (XAMPP). My OS is Windows 10. It is successfully executed on my laptop.
Now I am trying to access my project url (http://dms.zf.com:8084/newFieldsAdded/login.jsp) from another laptop but failed. So I searched the web and I got solution like this. I added
10.226.43.47 dms.zf.com
My laptop IP address and name into hosts (C:\Windows\System32\drivers\etc) file. Then I tried with this url (http://dms.zf.com:8084/newFieldsAdded/login.jsp) on my browser, it is successful. but it is not accessible from other laptop.
Before doing changes in hosts file url was http://localhost:8084/newFieldsAdded/login.jsp and after adding 10.226.43.47 dms.zf.com in hosts file URL is http://dms.zf.com:8084/newFieldsAdded/login.jsp.

vagrant up stuck on mount nfs

When I attempt to initiate 'vagrant up' the script executes as normal until it gets to the last line, where NFS shared drives are mounted.
I have tried deleting the exports file in /etc/ followed by a nfsd restart and vagrant destroy / vagrant up but to no avail.
After some considerable amount of time the console outputs the following [certain details redacted]:
*==> default: Mounting NFS shared folders...*
*The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed!*
*mount -o 'nolock,vers=3,udp,noatime' XXX.XXX.XX.X:'/Users/dhatton/Google Drive/moodle-doodle/site' /var/www/site*
*Stdout from the command:*
*Stderr from the command:*
*mount.nfs: Connection timed out*
UPDATE
The above problem was encountered when using a VPN into the office network. Upon logging in on-site without the VPN, everything works again.
For macOS Monterey 12.1 with virtualBox 6.1.30 and vagrant Vagrant 2.2.19/18:
create vbox folder in /etc
create a file inside /etc/vbox named networks.conf
add the following inside networks.conf
* 0.0.0.0/0 ::/0
Note: if you get the ip address range error, add your IP here too.
I had similar issue. I searched a lot, and tried following solutions:
Check /etc/exports and /etc/hosts files, if there are invalid entries in file, remove them.
Check your firewall is not blocking access
Restart NFS system
install vagrant plugin install vagrant-vbguest plugin
do vagrant reload --provision
Reboot your pc
Reinstall vagrant
For me reinstalling vagrant worked.
I've ran across this before and the problem turned out to be related to my companies VPN. If I tried running vagrant up connected to the VPN it would hang on mounting NFS, but if I disconnected from VPN and tried again it worked. Once running I could connect to VP Probably goes back to it needing a stable internet connection.
Assuming you are trying to mount from guest to host (host being OSX?) trying mounting to a different path. You might be encountering issues with the space in Google Drive?
Vagrant downloads binaries from its cloud while configuring a VM, so a stable internet connection is needed. In fact, an internet connection is necessary for using most of the Hashicorp products.

Hosts file in Windows 7 through Mac os X Parallels is being ignored

I'm using Mac os X with Parallels.
I am trying to set up a hosts file in windows.
The Hosts file in windows is ignoring my every attempt to update it.
127.0.0.1 www.altavista.com
google.com test
10.37.129.2 localhost
Any of these will not work when I try and ping test, localhost, or www.altavista.com
I have tried the following :
Deleting Hosts file, and recreating the file with "Edit as Administrator" while opening Notepad.
Clearing my cache, resetting my router, and rebooting Windows.
My host file is located in C:\windows\system32\drivers\etc\hosts
How is this being ignored?
Alright, so in Windows 7, everytime I saved the file, even though there was explicitly no extension set, it still set one, and wouldn't tell me.
So I went into Dos and did this :
rename hosts.txt hosts
Then make sure you reboot your Virtual Host or Windows .

Resources