Links pointing to localhost
What it is
The page contains one or more links to localhost or another local address such as 127.0.0.1, for example http://localhost:3000/pricing. Those addresses point to the computer the browser runs on. They work for a developer previewing the site on their own machine, and nowhere else.
Why it matters
On the live site, a visitor who clicks the link gets a connection error, or reaches whatever happens to run on their own computer. Crawlers cannot follow it either, so the page loses a working link and the page it meant to reach gets no credit. RFC 6761 reserves localhost for the loopback address. The link is also a sign that content was copied from a development or staging copy, which may have left other wrong addresses behind.
How Asky checks it
Asky reads every <a href> in the page’s raw HTML and resolves it against the page URL; links added by JavaScript are not seen. A link is reported when it is http:// or https://, scheme-relative //localhost included, and its host is localhost, a name ending in .localhost, a 127.x.x.x address, 0.0.0.0 or [::1], with or without a port. Staging domains, and these addresses in images, scripts or canonical tags, are not detected. Each such link also counts as an external link. It runs in every audit, selected pages included, on every page Asky fetched that answers without a 4xx or 5xx error.
Reported as an error with high severity.
How to fix it
- Open the finding to see the exact links, then search the page’s content, reusable blocks and menus in your CMS for
localhost,127.0.0.1and0.0.0.0. - Replace each link with the live page it meant to reach. A relative path such as
/pricingis safest, because it keeps working if the domain changes. - If the links arrived with a migration or a staging copy, search all content for the development address, including staging domains, which Asky does not detect.
- In WordPress, check that both addresses under Settings, General name the live site, and run a search and replace over the database after any migration.
Example
A link on https://example.com/blog/pricing-guide was copied from a local preview, so its href names the preview address on localhost, port 3000. Pointing it at the live page with a relative path fixes it:
<a href="/pricing">See our plans</a>