Forgive me if this has been answered, I searched and couldn't find anything. I have several servers running on my LAN that i want to be able to access via host name instead of IP and port number (e.x. ted instead of for my ted 5000 energy monitor) because it is shorter to type and easier to remember than IP : Port. especially when I am off network.

I have the entries added to the hosts file have flushed DNS cache using "dscacheutil -flushcache" but my computer is ignoring my hosts file and going right to my DNS servers

I had found the tip of creating a second hosts file in the users home directory containing only "LookupOrder Cache NI FF DNS DS" and that has made no change ether.

I also read "You can enter the hostnames in netinfo (in Applications/Utilities)" elsewhere but I don't have netinfo in Applications/Utilities

On my windows machines all I need to do is edit the hosts file, flush DNS and I am up and running, any help would be greatly appreciated.

Dani AI

Generated

Good catch, — the hosts mechanism only maps names to IP addresses, it does not (and cannot) carry port information. DNS and /etc/hosts operate at the address layer; ports are chosen by the client application. That’s why changing hosts won’t remove the need to type :5000.

Practical ways to avoid typing the port number:

  • Run the service on a standard HTTP/HTTPS port (80 or 443) so the browser can omit the port. Note that binding to ports below 1024 typically requires elevated rights.

  • Put a local reverse proxy (nginx/apache) on port 80 that forwards requests to your service on :5000. Example nginx server block:

    server {
        listen 80;
        server_name ted;
        location / {
            proxy_pass http://173.166.39.161:5000;
            proxy_set_header Host $host;
        }
    }
  • Use a simple port-redirect on the machine or router (forward external 80 to internal 5000) or run an SSH tunnel / VPN when you are off‑network so the remote client sees the service on a standard port.

For remote access (you mentioned “off network”): use dynamic DNS plus router port forwarding (with HTTPS and authentication), or avoid exposing the service by using a VPN or a secure reverse tunnel (SSH/ngrok/Cloudflare-type tunnel). Exposing internal services directly to the internet without encryption/auth is risky.

Quick troubleshooting checklist for macOS name resolution:

  • Confirm /etc/hosts entries are correctly formatted (IP then hostname) and the file isn’t accidentally saved with an extension.
  • Check file permissions so the system can read it.
  • Remember some browsers do DNS prefetching or have their own caches — try restarting the browser.
  • NetInfo was an old macOS mechanism; modern macOS uses hosts, mDNS/Bonjour and system resolver services, so you won’t find NetInfo in current Utilities.

Because the hosts file can’t include ports, a reverse proxy or port mapping is usually the cleanest and most secure way to let you type “ted” instead of “ip:5000.”

Never mind... I am miss-remembering that the hosts file could support port numbers

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.