Questions tagged [hosts-file]

The hosts file is a computer file used in an operating system to map hostnames to IP addresses. The hosts file is a plain text file and is conventionally named hosts.

The hosts file is one of several system facilities that assists in addressing network nodes in a computer network. It is a common part of an operating system's Internet Protocol (IP) implementation, and serves the function of translating human-friendly hostnames into numeric protocol addresses, called IP addresses, that identify and locate a host in an IP network.

In some operating systems, the hosts file's content is used preferentially to other methods, such as the Domain Name System (DNS), but many systems implement name service switches (e.g., nsswitch.conf for Linux and Unix) to provide customization. Unlike the DNS, the hosts file is under the direct control of the local computer's administrator.

More see at Wikipedia

148 questions
4
votes
1 answer

Windows: How to use hosts file with path?

This works: 127.0.0.1 www.somesite.com But not this: 127.0.0.1/somepath/www www.mysite.com What am I doing wrong? Is it possible to map a full path like this? If not, what is the easiest way to accomplish what I want to do here?
rockstardev
  • 13,479
  • 39
  • 164
  • 296
3
votes
2 answers

DNS resolving based on client IP

I want to configure bind/write driver that resolves DNS requests based on the ip address of the client. We want to unify the domain names of all test environments for our web application. Instead of having many domains like test.mysite.com,…
devdimi
  • 2,432
  • 19
  • 18
3
votes
1 answer

How to set up custom hostnames and ports for servers (eg node.js) running in WSL 2

(I've provided a simple working solution in response) I recently moved from macOS to WSL 2. I have two node servers running within WSL 2 (Ubuntu distro). Each must be accessible through a custom hostname for development vs production purposes. I've…
MoMo
  • 1,836
  • 1
  • 21
  • 38
3
votes
1 answer

Hosts file ANTLR grammar

Is there an existing, working hosts file grammar on the web? I checked out list on http://www.antlr.org/grammar/list, but I didn't find it there. I also checked the hosts file entry in Wikipedia, and it referenced RFC 952, but I don't think that is…
Merlyn Morgan-Graham
  • 58,163
  • 16
  • 128
  • 183
3
votes
2 answers

IKVM C# to Java Interop with Callback using IKVM

I've started using IKVM to translate Java libs into .NET CIL. I can successfully write a C# program that pulls in (inproc) a translated Java assembly as a reference and make calls to the translated Java code. My question is, is anyone familiar w/…
mj_
  • 6,297
  • 7
  • 40
  • 80
3
votes
1 answer

Make one Docker Compose service know the domain name of another

I'm using Docker Compose to create two containers. One runs an Nginx web server which serves the mydomain.com website, and the second needs to send HTTP requests to the first one (using the mydomain.com domain name). I don't want to have to check…
marcv
  • 1,874
  • 4
  • 24
  • 45
3
votes
1 answer

Selenium: Is there a way to change the hosts file on the machine the server is running on

I want to make the browser open a local url with a name of the live url. Meaning that when I do: sel.open('http://live-url/) selenium will actually open the local url. One would test this by changing it's hosts file but this is impossible when…
Guy
  • 14,178
  • 27
  • 67
  • 88
3
votes
1 answer

What permissions should /private/etc/hosts have on Mac OS X 10.8.2

I had multiple terminal windows open using SSH to access a webserver behind reverse proxies and was making changes to my hosts file to alternate between the webserver and public ip. While not paying attention I accidently executed sudo chmod 777…
James
  • 3,233
  • 3
  • 40
  • 57
3
votes
4 answers

Switching up the hosts file in a development environment

While developing websites (using win7) I find myself changing the IP addresses in my hosts file quite often. I have a development environment on my machine, code on the testing server, code on the staging server and code on the live server. I…
Michael Gorham
  • 1,234
  • 2
  • 16
  • 24
2
votes
1 answer

Windows - Private hosts file for a certain environment

I've an application running on a dev server and connecting to a dev-db hosting an oracle instance. Now i'm deploying the on a prod/prod-db machine Since the dev-db url is hardcoded inside the java code, the just-copied binaries still points to…
Gabriele B
  • 2,665
  • 1
  • 25
  • 40
2
votes
0 answers

Unable to access website added in hosts file in MAC OSX

I have added a hostname in the /etc/hosts/ file in Mac OSX,when i try to run the URL with the hostname in the browser i couldn't able to access it , but when i try to access it with IPAddress I could able to access it. Observations: 1)I can able to…
Fedrick
  • 527
  • 2
  • 8
  • 26
2
votes
1 answer

How to change the URL from “localhost” to something else, on a local system using Flask?

On a Windows machine, there's a system running on the local FLask server, but while the application is running on localhost. While the Default I would expect the URL to be like this based on the directory structure: http://localhost/swagger But The…
2
votes
0 answers

Android add domain and ip to hosts file programmatically

I want to set temporary domain and ip to hosts file. which only activate when the app is running. i want to make app work like Hosts go which works well on not rooted too. what i'm trying to do is the server is running on Lan computer. so when app…
krozero
  • 5,929
  • 3
  • 21
  • 33
2
votes
4 answers

using bash with sed how to extract ip from a hostname command and saving it in /etc/hosts file

I want to store an entry in the /etc/hosts file for the IP of the box that I am on. When I run the following command I get: :-$ hostname ip-10-55-9-102 I want to store this entry in /etc/hosts as following: Expected result: 10.55.9.102 …
Saffik
  • 911
  • 4
  • 19
  • 45
2
votes
1 answer

Checking hosts file entry with PHP?

I'm creating a 'domain locking' script. Basically, the script will check my website to make sure that the host its running on is allowed to run it. I don't want them to be able to modify their host file to reroute the connection. Is there a way to…
Rob
  • 7,980
  • 30
  • 75
  • 115
1 2
3
9 10