Как открыть локалхост в браузере
Перейти к содержимому

Как открыть локалхост в браузере

  • автор:

 

How do I go to localhost in Chrome?

EDIT: This issue is no longer reproducible with Chrome 70.x.

When I type localhost into used-to-be-an-address-bar in Chrome and hit Enter, Chrome takes me to google.com to search for «localhost».

If I don’t hit Enter, a drop-down drops down with options like:

  • Search for localhost
  • Go to localhost/some/path that I have previously visited
  • Go to otherRecentLocation.someDomain/blah?thing=localhost&so=on

(Hitting Enter of course selects the first of those options.)

Notice that going to localhost is not an option at all. While the other options are nice, one would expect the ability to go to a valid location like localhost , and moreover that it be the default—i.e. typing localhost and hitting Enter should take you to, literally, http://localhost:80 . I was able to go to localhost a few days before posting this originally (3 days ago). Was this changed as a security feature?

My intent is to test that the web application I am developing is correctly configured to respond with the right payload, e.g. index.html.

Specs: — Chrome Version 69.0.3497.100 (Official Build) (64-bit) — Ubuntu 16.04 — running an application at https://localhost, which I can access with workarounds.

Let me know if I should post this question in a different StackExchange site.

localhost

Если вы хотите перейти на http://localhost, то воспользуйтесь быстрыми ссылками для входа:

  • http://localhost
  • http://localhost:8080
  • http://localhost:8081
  • http://localhost/phpmyadmin
  • http://localhost/WordPress
  • http://localhost:3000
  • http://localhost/php
  • http://localhost/index
  • http://localhost/index.php
  • http://localhost/server
  • http://localhost/bonfire

Что такое localhost

localhost — это универсальное имя хоста, которое всегда указывает на этот же самый компьютер. Точнее говоря, это имя указывает на IP адрес 127.0.0.1, а данный IP уже является специальным адресом, всегда принадлежащий локальному компьютеру.

Если открыть адрес http://localhost в веб-браузере, то будет выполнено подключение к локальному веб-серверу. По этой причине localhost обычно ассоциируется с веб-сервером, но на самом деле localhost можно использоваться самыми разными сетевыми службами: программами для обмены данными между собой, MySQL, SSH, FTP и пр.

Вы можете даже пинговать localhost:

Пинги будут самыми лучшими из всех, какие вы когда-либо видели, поскольку проверяется соединение до этого же самого компьютера, на котором выполняется пинг.

Про loopback будет чуть ниже — на случай, если вам интересна теория, а сейчас рассмотрим, почему не работает localhost.

Как включить localhost

Возможно вы и так знали, что localhost это локальный веб-сервер, но при попытке открыть

http://localhost у вас возникает ошибка, например такая:

Не удается получить доступ к сайту

Сайт localhost не позволяет установить соединение.

Попробуйте сделать следующее:

Проверьте подключение к Интернету.

Проверьте настройки прокси-сервера и брандмауэра.

ERR_CONNECTION_REFUSED

Причин может быть несколько, самая популярная — вы просто не установили веб-сервер. Если это действительно так, то переходите к инструкции «Как установить веб-сервер Apache c PHP, MySQL и phpMyAdmin на Windows».

После завершения указанной инструкции localhost заработает!

Веб-сервер установлен, но localhost не открывается

В этом случае причины могут быть следующие:

  • веб-сервер установлен, но его служба не запущена (особенно если раньше работало, а после перезагрузки перестало работать) — вернитесь к инструкции по установке, запустите службу веб-сервера и добавьте её в автозагрузку;
  • неправильно настроены права доступа в веб-сервере, либо ошибка в конфигурации — вернитесь к настройке веб-сервера или переустановите его.

127.0.0.1

127.0.0.1 — это специальный IP адрес, который имеет loopback интерфейс. В любой операционной системе имеется поддержка 127.0.0.1, поскольку этот специальный IP описан в протоколе.

Суть работы 127.0.0.1 (а следовательно и localhost, который является именем для указания на этот IP) состоит в том, что пакет, отправленный на адрес 127.0.0.1 на самом деле никуда не отправляется, но при этом система начинает считать, что этот пакет пришёл из сети. То есть образно можно представить так: пакет отправляется на сетевую карту компьютера, там разворачивается и возвращается с сетевой карты обратно в компьютер.

Несмотря на кажущуюся бесполезность, такой подход очень популярен и используется для взаимодействия с самыми разными программами.

http://localhost:8080

Чтобы подключиться к localhost на 8080 порту перейдите по ссылке http://localhost:8080

localhost php

Чтобы использовать PHP на своём компьютере нужно установить веб-сервер. Пошаговую инструкцию смотрите в статье «Как установить веб-сервер Apache c PHP, MySQL и phpMyAdmin на Windows».

localhost phpmyadmin

Аналогично, для получения phpMyAdmin установите веб-сервер.

localhost error

Ошибки могут возникнуть в случае неправильной установки веб-сервера или приложений. Смотрите «Ошибки при настройке и установке Apache, PHP, MySQL/MariaDB, phpMyAdmin».

Как открыть локалхост в браузере

When you (or your computer) call an IP address, you are usually trying to contact another computer on the internet. However, if you call the IP address 127.0.0.1 then you are communicating with the localhost – in principle, with your own computer. But what is the point of starting a virtual conversation with yourself? What do you need the localhost for and how does it work?

Register great TLDs for less than $1 for the first year.

Why wait? Grab your favorite domain name today!

Matching email
SSL certificate
24/7/365 support

 

What is localhost?

The first point to make when explaining what a localhost is, is that it is always your own computer: when you call the localhost, your computer is talking to itself. However, this is a condensed approach. The localhost is not always directly identified with your computer. In most cases, it has a separate IP address like 192.168.0.1. within your personal network, which is different to the one you use on the internet, and is usually dynamically assigned by the internet service provider. When you are talking about a localhost, you are referring to when a server is used on your own computer.

Conversely, this means that the term is only used in the context of networks. “Localhost” is not just the name for the virtual server, but also its domain name. Just like .test, .example or .invalid. .localhost is a top-level domain reserved for documentation and testing purposes. When you try to access the domain, a loopback is triggered. If you acces «http://localhost» in the browser, the request will not be forwarded to the internet through the router, but will instead remain in your own system. Localhost has the IP address 127.0.0.1, which refers back to your own server.

localhost

Exemplary representation of the communication between a web browser and web server within a local computer

127.0.0.1 – how does loopback work?

IP addresses are used within a network to communicate with each other. Each participant in the network has their own address. Data packets sent via TCP/IP are able to reach the correct destination when this system is used. The protocol pair Transmission Control Protocol (TCP) and Internet Protocol (IP) are some of the cornerstones of the internet. However, TCP/IP is also used outside the internet, in local networks. During transmission, the Internet Protocol is responsible for allowing the IP address and subnet mask to address subscribers in a network.

The allocation of public IP addresses (those that can be reached through the internet) is regulated by an international organization: the Internet Corporation for Assigned Names and Numbers (ICANN). ICANN is also responsible for the allocation of domain names, or the Domain Name System (DNS). However, certain address ranges are reserved for special purposes, like the range from 127.0.0.0 to 127.255.255.255. There is no reliable information on why that range was chosen, but you are free to speculate.

Until the 1990’s, IP addresses on the internet were divided into different classes. The first class (Class A) started with 0.0.0.0 (this address is also reserved) and ended with 127.255.255.255. 127 is the last block within the Class A network. This important position could have been the reason why it was chosen.

A Localnet can be set up within this address range. The special thing about this range is not only that it was reserved by ICANN, but is also that IP addresses are not uniquely assigned in it, as is usually the case. But how does it work?

With IPv6, the address ::1 is reserved for loopbacks.

For example, if you enter an IP address (or corresponding domain name) in your browser, the router will forward your request to the internet and to the correct server. This means that if you enter 172.217.0.0, you will reach the Google homepage. However, the situation is different with 127.0.0.1 because requests to this address will not be forwarded to the internet. TCP/IP recognizes from the first block (127) that you don’t want to access the internet, you are calling yourself instead. This then triggers the loopback.

Conversely, the protocol does not accept external requests addressed to 127.0.0.1, as it would mean that attackers could try to sneak into their system. Packets reportedly appearing on the internet from reserved IP addresses like 127.0.0.1 are known as Martian Packets.

A loopback device is created so that the back link to your own computer works. This is a virtual interface that is created through the operating system. With Unix systems, the interface is called lo or lo0 and can also be displayed using the ifconfig command. A similar command for Windows is ipconfig.

If you consider the technology independently of the local host, a loopback can be created in an analog way: circuits in communication technology can then be used to determine whether the paths taken by the signal and the reception are correct.

What is localhost used for?

Developers use the local host to test programs and web applications. Network administrators can also use the loopback to test network connections. Another practical use for the localhost is the hosts file, where you can use the loopback to block malicious websites.

For Testing Purposes

Localhost’s main use in web servers is for programming applications that need to communicate over the internet. During development, it is important to find out whether the application actually works as hoped once it has internet access. Localhosts’ other functions are only possible if the required files can be found on the internet — for example, there is a difference between opening a HTML document on your PC or loading it onto a server and accessing it. Releasing an unfinished product without testing it doesn’t make sense, so developers use a loopback to test them. They can stimulate a connection while also avoiding the network detour: the connection instead just stays completely inside their own system.

Another advantage of using localhost for testing purposes is its speed. When you send a request over the internet, it takes more than 100 milliseconds. If you send a ping to localhost, the maximum transmission time is just one millisecond. With this technology, you can also find out whether or not the Internet Protocol is correctly implemented. To test this yourself, just open the command prompt (Windows) or terminal (Unix/Mac) and use the ping command. You can either send it to the domain localhost or directly to the IP address.

If you want to set up your own test server on your PC to address it through the localhost, you first need to install the right software. It is generally possible to run any standard web server on your own computer, but there is also special software specifically designed for use as a localhost – XAMPP for example. We provide a step by step guide for how to install and configure the test system in our Digital Guide.

SSL certificates from IONOS

Protect your domain and gain visitors’ trust with an SSL-encrypted website!

Localhost не может быть открыт

localhost являетсядоменное имяОбычно указывает на 127.0.0.1, поэтому они обычно приравниваются.

Но после ipv6 localhost также указывает на адрес ipv6 [:: 1],
ipv6 имеет высокий приоритет, поэтому при пинге он будет указывать на [:: 1] по умолчанию.

[:: 1] является коротким для 0: 0: 0: 0: 0: 0: 0: 1 и представляет локальный адрес обратной связи в IPv6, который эквивалентен 127.0.0.1 в IPv4.

If Проверьте, соответствует ли 127.0.0.1 localhost

Пинг 127.0.0.1 и localhost в командной строке

Результат сопоставления, полученный двумя эхо-запросами, должен быть одинаковым, оба 127.0.0.1:
 : ping , 127.0.0.1:
Если он не совпадает, ping localhost вернет :: 1: вместо 127.0.0.1

❤ Что мне делать, если 127.0.0.1 не соответствует localhost?

В основном это следующие решения:

Решение 1. Проверьте / переустановите IIS

Тест: откройте http://127.0.0.1 в браузере
Если следующая страница по умолчанию не может появиться, возникла проблема с IIS, переустановите ее:

способ установки:
Откройте панель управления — Программы и функции — Включите или отключите функцию Windows — Проверьте 2 IIS (необходимо развернуть все, чтобы проверить все)

Решение 2. Просмотр локального хоста

Если IIS в порядке, или он не будет работать после переустановки, проверьте хост


Откройте хосты, чтобы увидеть, не добавлены ли следующие две строки.

В это время вам может быть предложено, что нет разрешения. Сначала вы можете перетащить хосты на рабочий стол, а затем заменить его.

Решение третье: изменить приоритет

Если два вышеуказанных решения по-прежнему не используются для решения проблемы, вы можете изменить приоритет IPv6.

Введите команду netsh interface ipv6 show prefixpolicies для запроса приоритета ipv6

Адреса IPv6 (:: / 0) имеют приоритет над адресами IPv4 (:: / 96, :: ffff: 0: 0/96)

Выше метка обозначает приоритет, 0 обозначает наивысший приоритет и так далее.

Однако мы можем установить приоритет :: / 96, :: ffff: 0: 0/96 выше, чем :: / 0 и :: 1/128, установив в командной строке следующий порядок:

После окончания введите команду netsh interface ipv6 show prefixpolicies, чтобы снова проверить приоритет:

Результат отображается следующим образом: :: / 96, :: ffff: 0: 0/96 Приоритет выше, чем :: / 0.

Затем, если мы снова пингуем localhost, мы можем получить тот же результат, что и ping 127.0.0.1.

Решение четвертое: изменить реестр

Когда я использовал третий вариант, моя проблема была решена, поэтому я не пробовал четвертый вариант лично. Если вы еще не решили, вы можете попробовать изменить реестр. Примерные шаги модификации в Интернете следующие:

 

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *