Questions tagged [hosts]

A `hosts` file is used to map hostnames to IP addresses on a TCP/IP-enabled computer.

A hosts file is used to map hostnames to IP addresses on a TCP/IP-enabled computer. On Unix and Unix-like operating systems (Linux, OSX, FreeBSD, NetBSD, et al), the file is located at /etc/hosts. In Microsoft Windows, the file may be located in different places depending on the version of the operating system. In Plan 9 from Bell Labs it is located at /lib/ndb/hosts

On most systems, the behaviour of /etc/hosts depends on configuration within the /etc/nsswitch.conf file.

786 questions
302
votes
20 answers

Wildcards in a Windows hosts file

I want to setup my local development machine so that any requests for *.local are redirected to localhost. The idea is that as I develop multiple sites, I can just add vhosts to Apache called site1.local, site2.local etc, and have them all resolve…
EvilPuppetMaster
  • 7,052
  • 9
  • 31
  • 30
129
votes
11 answers

How to update /etc/hosts file in Docker image during "docker build"

I want to update my /etc/hosts file during "docker build". I added below line in Dockerfile but it's neither updating /etc/hosts file nor giving any error. RUN echo "192.168.33.11 mynginx" >> /etc/hosts I need to update /etc/hosts. Can anyone…
Prakash
  • 1,742
  • 3
  • 12
  • 19
123
votes
7 answers

Set cURL to use local virtual hosts

Using Apache or Ngnix I always create development sites based on real projects such as http://project1.loc which, after adding to my .hosts file, the browser has no problem using. However, when I attempt to make a cURL request…
Xeoncross
  • 50,836
  • 73
  • 238
  • 351
119
votes
17 answers

How can I redirect HTTP requests made from an iPad?

Since on an iPad we cannot edit the hosts file (without jailbreaking), how can we arbitrarily redirect web traffic to another url? This would be important for something such as developing a website that uses a Virtual Host configuration where you…
tremoloqui
  • 3,118
  • 3
  • 22
  • 21
94
votes
4 answers

Using --add-host or extra_hosts with docker-compose

I am using docker-compose to run a test environment, that consists of about 5 different containers. The inter-container links and the shared volumes (volumes-from) works wonderfully. I also expose some ports up to the host machine, which works…
Pieter
  • 1,323
  • 2
  • 9
  • 13
92
votes
13 answers

Can I edit an iPad's host file?

I doubt this is possible without extensive jail-breaking, but is it at all possible to edit the iPad's (or any iOS device's) hosts file?
Ahmed Nuaman
  • 11,324
  • 13
  • 50
  • 80
92
votes
3 answers

How to put wildcard entry into /etc/hosts?

I recently wanted to point all subdomains for a test domain, let's say example.com to the localhost. Is there a way to point all requests on *.example.com to resolve to 127.0.0.1
aamir
  • 3,053
  • 3
  • 17
  • 31
86
votes
5 answers

How to add more than one machine to the trusted hosts list using winrm

To run powershell commands on a machine from a remote machine we have to add the remote machine to the trusted hosts list of the host machine. I am adding machine A to machine B's trusted hosts using the following command : winrm set…
cmm user
  • 1,936
  • 6
  • 32
  • 47
75
votes
10 answers

Why does Microsoft Edge open some local websites, but not others, where the domain name is routed to 127.0.0.1 in hosts file

Like a lot of programmers, I test sites locally. I use the hosts file to map domain names to my local ip (127.0.0.1). I use qualified domain names, usually with a "d" subdomain (for "development"). For example: d.somewebsite.com…
Evan de la Cruz
  • 1,912
  • 1
  • 12
  • 15
72
votes
4 answers

How to change the hosts file on android

I have successfully rooted my Samsung Galaxy Mini (android 2.2.1) and thought, that I could change anything (as root usually can). I would like to change the hosts file on the android, to include some local addresses. However, I still get the…
Filip Majernik
  • 7,350
  • 13
  • 39
  • 51
55
votes
7 answers

Google Chrome Ignoring Hosts File

Google Chrome is ignoring the settings in C:/Windows/System32/drivers/etc/hosts file. Both IE11 and Firefox are installed on the same machine and work as expected. I've tried all the solutions I could find online including: Open…
Nick Petrie
  • 4,542
  • 9
  • 36
  • 48
44
votes
3 answers

How do I set up the hosts file for multiple domains/hosts with the same IP?

As you surely know you can map host names to IP addresses with the "hosts" file. This is very useful especially when you are developing as you can change localhost for project1. That part is clear, but unfortunately I can't figure out how to set…
Vinicius Santana
  • 3,216
  • 2
  • 23
  • 39
32
votes
6 answers

Editing hosts file to redirect url?

I know you can edit a hosts file to redirect a URL to an IP address as so: 127.0.0.1 google.com but how do you force a redirect to a URL instead of an IP address? e.g. mysite.com/welcome.aspx google.com The explicit URL doesn't work and assuming…
Glory
  • 411
  • 1
  • 5
  • 5
31
votes
4 answers

Force fact-gathering on all hosts

I'm sitting in front of a fairly complex Ansible project that we're using to set up our local development environments (multiple VMs) and there's one role that uses the facts gathered by Ansible to set up the /etc/hosts file on every VM.…
tehK
  • 2,015
  • 3
  • 14
  • 16
29
votes
8 answers

Windows Batch: How to add Host-Entries?

I want to use this batch script to add new entries into my host file automatically by using windows batch. Unfortunately, the script just adds one single line to the hosts file, also when i run the script as a administrator, so what's wrong? @echo…
mate64
  • 8,500
  • 15
  • 58
  • 93
1
2 3
52 53