Hello All I've set up a subdomain on a VM of mine under the name 'test.localhost' on that 'VM'. However when I try to access that VM via the browser on my local machine i get an error when I do test.my_ip_address. (my_ip_address actually being the vm ip!)

Is there anyway I can access this subdomain not paying for a a domain name for it?!?

Thanks!!!

Dani AI

Generated

Quick practical summary: the easiest way to reach a name like test.something hosted inside a VM is to make your host resolve that name to the VM's IP (edit the hosts file) and make sure the VM is actually reachable from the host (network mode). As hinted, check connectivity first; if the virtualization networking is NAT you either need port‑forwarding, or you should switch the VM adapter to bridged or host‑only so the host can talk to the VM directly. (virtualbox.org)

Checklist to get this working

  • Verify the VM IP from inside the VM and test reachability from the host (ping or curl the VM IP).
  • If you use NAT, configure port forwarding for the HTTP(S) ports on the VM or use bridged/host‑only networking so the VM gets an IP on the same network. (virtualbox.org)
  • For a single workstation the simplest name resolution is the hosts file (one-line mapping on your host machine). See the editing notes below. (howtogeek.com)

Hosts file example (add as administrator/root)

192.168.1.42    test.mydevsite

Use the VM IP, not a mixed form like test.1.2.3.4. If your webserver is bound only to 127.0.0.1 inside the VM it still won’t accept external connections; ensure the server listens on 0.0.0.0 or the VM’s IP.

Important naming cautions: avoid using the literal .localhost or plain .local names for this purpose. Names ending in .localhost are reserved and normally map to loopback, and .local is treated by mDNS (Bonjour/Avahi), which can cause surprising resolution behavior. Prefer a name like test.mydevsite or test.internal in your hosts file. (datatracker.ietf.org)

If the hosts file approach still fails, post the VM network mode, the IP you see inside the VM, and any server bind/listen config — those details pinpoint the remaining issue. As discovered, copying the app locally sidesteps the network work, but fixing the VM setup keeps your host clean and is worth learning.

Recommended Answers

All 3 Replies

Paying for a domain name is not the issue here. You can host any domain name you want within your own network assuming that your host name resolution (DNS) architecture is configured accordingly.

When you say that you set up a subdomain on a VM... What do you mean exactly? Did you set up an Active Directory Domain, or did you just setup a web server and are trying to host a website on this domain name?

I assume that you are hosting a web server on the VM.

Regardless, the first step is to ensure that you have connectivity between the host and VM. Secondary, you need to have something in place to be able to resolve the host name "test.localhost". The easiest method for a single name such as this is to modify the HOSTS file on your HOST computer and point this hostname to the IP address of the VM.

What virtualization software are you using on the HOST computer?

test.my_ip_address

Regarding this format, I am not sure what you are trying to do... that's not the proper syntax for a host name. You can either try to connect via IP or hostname, but not a mix of both.

To be honest I'm complete 'noob' when it comes to networking, I mostly just do web programming. I decided to give up on that idea and just copy down the whole application from my VM to my local machine. I was able to get the same effect.

Thanks though for the quick response though :)

ok, glad you at least found a solution. If you dont have experience with virtualization and networking, it introduce quite a bit of challanges until you have all of the components setup. I suggest that when you have more time, revisit the vm option. Its a good way not to cluter your host computer because when you are done with development and testing, you can simply delete the VM.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.