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.

841 questions
9
votes
3 answers

Can't update hosts file on mac

When I try to save changes made in /etc/hosts file on mac i get this error: "hosts" E212: Can't open file for writing How can I update it?
Renat Gatin
  • 6,053
  • 5
  • 37
  • 58
9
votes
2 answers

How to force Apache Bench to use IP addresses specified in /etc/hosts?

I'm using ApacheBench to do some load testing. I'd like ab to resolve the hostname using the IP address specified in /etc/hosts on my Mac. How can I force that? curl has a --resolve option to do exactly this, as specified here. I'm looking for…
tinkerr
  • 975
  • 2
  • 14
  • 32
9
votes
1 answer

Can the hosts file redirect an IP address?

I have cloned a Windows 2003 machine and put it on the same domain as the original. I want to make sure that the clone never accesses the original. I want it to think it is the original. I don't want to exhaustively check the clone for everything…
cja
  • 9,512
  • 21
  • 75
  • 129
8
votes
1 answer

Hosts file hostname not being returned in c# ASP.NET MVC

I am currently testing a site with multiple sub domains pointing to the same ASP.NET application, and the routing handles what to do with each request. For testing, I have added several sub domains to my "hosts file", e.g. "127.0.0.1…
Paul Grimshaw
  • 19,894
  • 6
  • 40
  • 59
8
votes
0 answers

No access to host.docker.internal in Docker for Windows

In .Net Framework application made in VS (application is build and deployed by VS) I tried to access my local database from Docker using host.docker.internal but this is not resolved, when try to ping it, I get this: Ping request could not find host…
Zixav
  • 131
  • 1
8
votes
2 answers

What language option should I use in Notepad++ with my windows host file for readability?

Maybe this is a silly question, but today I was working in my hosts file (C:\windows\system32\drivers\hosts) in notepad++ and would like to use the language formatting. For example, the first line appears to be a comment # Copyright (c) 1993-1999…
Josiah Ruddell
  • 29,697
  • 8
  • 65
  • 67
8
votes
3 answers

Mac OSX changing /etc/hosts has no effect even after killing mDNSResolver

I have not had a similar issue in Windows (10) and nothing I've searched on docs seems to indicate why, if this does not work, that that is the case I open up terminal and edit /etc/hosts (which I've done many times on a PC and a few years back on…
Oliver Williams
  • 5,966
  • 7
  • 36
  • 78
8
votes
1 answer

--add-host parameter in Marathon docker application

I have docker images (with entrypoints) that I would like to run using Mesos and Marathon. These images require changes in /etc/hosts and /etc/resolv.conf. When I typically run this I would do something like: docker run --add-host host:ip…
Erik Nguyen
  • 839
  • 1
  • 6
  • 21
8
votes
2 answers

Change my hosts file to route to a folder and not an ip

Fairly new freelance developer and I'm looking to add a local version of a website im working on for a dev environment. I've got my localhost set up. 127.0.0.1 localhost The syntax that I was using but is evidently not correct…
monkeymanbob
  • 93
  • 1
  • 1
  • 3
8
votes
2 answers

How to remove port number from http://localhost:8123 to use as http://localhost?

I had to change my default apache port number 80 to 8123 (just random number) I changed the following files .. httpd.conf Listen 8123 ServerName localhost:8123 httpd-vhosts.conf NameVirtualHost *:8123 ServerName localhost …
user1421214
  • 909
  • 4
  • 17
  • 24
8
votes
1 answer

Run different PHP versions on virtual hosts in apache 2.2

How can I configure Apache 2.2 server to have PHP 5.3 in all virtual hosts, except one virtual host in which to run PHP 4.4? I have all the php and .dll files.
CoursesWeb
  • 4,179
  • 3
  • 21
  • 27
8
votes
1 answer

Are there any alternatives to hosts file for accessing virtual hosts from multiple PCs?

I have several virtual hosts set up on my PC running WAMP. All the other PCs in the office need to be able to access these too. Traditionally, every time I added a new virtual host to my PC, I need to go to all of the other office PCs and modify…
user1578653
  • 4,888
  • 16
  • 46
  • 74
7
votes
1 answer

How do I add a host to my permitted rails hosts dynamically?

I need to dynamically add a permitted host to my Rails 6 application during runtime. I've managed to append to Rails.application.config.hosts at runtime, but I'm still receiving an error Blocked host. Rails appears to ignore the hosts added to…
Alan
  • 1,510
  • 1
  • 18
  • 35
7
votes
2 answers

Rename localhost to custom domain using webpack dev server?

I'm trying to rename my localhost that I use on development. I have updated my C:\Windows\System32\drivers\etc\hosts file and added this line (ran as Administrator): # copyright (c) 1993-2009 microsoft corp. # # this is a sample hosts file used by…
cbdeveloper
  • 27,898
  • 37
  • 155
  • 336
7
votes
0 answers

webpack-dev-server - localhost not working 127.0.0.1 does work

This one is a real head-scratcher. I've been using webpack-dev-server and localhost does not work on my computer, although it does on other people's computers, with the same setup. I can access 127.0.0.1 on the same port (any open port is working…
Brian Jenkins
  • 349
  • 1
  • 6
  • 22