Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/etc/hosts file not redirecting to local application on mac

Tags:

macos

hosts

I've set up a redirect in the hosts file on my machine that basically points an auth domain to my local project in IIS (when run in Visual Studio for Mac) - however when I type the domain name into Chrome (for example), I get a message saying this site cannot be reached.

The local URL I want this to point to is: http://localhost:44380/ - the live URL I can't reveal for security but lets say for the sake of this example that it's: auth.site.com (the actual URL I'm using is valid and it does load in Chrome)

Here's my hosts file from terminal as it's currently set up:

##
# 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
127.0.0.1       auth.site.com

I'm very familiar with windows and how the hosts file works, so from what I know there this would work in windows (I think anyways), is there something I'm missing here because obviously something isn't right?

like image 701
Web Develop Wolf Avatar asked Sep 19 '25 19:09

Web Develop Wolf


1 Answers

I would first check where the problem is exactly. I think of the following possible issues:

  1. Hosts file not properly working: Try running ping auth.site.com in a terminal. If you see responses from 127.0.0.1 this should work.
  2. Is access to the port possible, open http://localhost:44380 in your browser. If you see your page, this should work.
  3. Combine the two parts: open http://auth.site.com:44380 in your browser. If this does not work, maybe there are security features from the original page you visited before preventing access (like forcing SSL or a pinned certificate).
  4. Try another browser or curl auth.site.com:44380 in a terminal.

If you are not happy with the given ports, you can do a port forwarding. Changing ports is not possible in the hosts file, because the hosts file is only for domain name lookup and this has nothing to do with the ports.

like image 116
Itchy Avatar answered Sep 21 '25 17:09

Itchy