# myIpAddress()

Source: https://findproxyforurl.net/functions/myipaddress/ · last updated 2026-10-15

`myIpAddress()` → string

Returns one IP address of the computer that runs the PAC file. Which one depends on the engine, the routes and the adapter settings, so it is not guaranteed to be the address your PAC logic expects.

A computer usually has several addresses: one per network adapter, VPN adapters, virtual adapters
and IPv6 addresses. `myIpAddress()` returns only one of them, and each engine chooses it by its own
rule. Chrome, Edge and Firefox look at the route towards the internet. Windows' own proxy engine
looks at the interface metric, which is the order of the adapters in Windows. pactester looks
at the computer's name. The answer can also change while the computer runs: when a VPN connects,
when Wi-Fi and cable are both in use, or when Windows stops using a gateway that does not answer.

The measured examples below come from one Windows 11 computer with several network adapters.
They show that the same file can get a different address in each engine. Other setups can give
other answers, so treat the examples as examples, not as rules.

A PAC file therefore should not decide where a computer is from `myIpAddress()`. Serve a
separate PAC URL per location (by DHCP or group policy), or let the proxy decide by the client's
source address.

## Example

```js
// Shows which address this engine returns (Firefox: browser console; Chrome: net-export log).
alert("myIpAddress() = " + myIpAddress());
```

## The same computer got a different address from each engine

| Network setup | Chrome / Edge | Firefox | Windows (WinHTTP, WinINet) |
|---|---|---|---|
| `Only A has an address and the route to the internet; the other adapters got no address from DHCP (169.254.x.x).` | A | A | A | 
| B has the route to the internet. A comes first in Windows' adapter order. | B | B; for a URL whose host is an IP address in A's network: A | A | 
| A has the route to the internet. C has the lowest interface metric but no route to the internet. | A | A | C | 
| B has the route to the internet. C has the lowest interface metric but no route to the internet. | B | B | C | 
| B and C both have a route to the internet with the same metric. | the one Windows uses (B) | the one Windows uses (B) | A, the first adapter in Windows' order | 
| B has the route to the internet, but its gateway does not answer. | B at first, then A once Windows moved to the next route (within seconds) | B or A, different from one page load to the next | A | 
| All adapters except A are switched off. | A | A | A | 
| `A VPN (V) with full tunnelling takes the route to the internet; A has the physical connection.` | V | V; for a URL whose host is the VPN server's address: A | V | 
| The same VPN while B had the route to the internet before it connected. | V | V; for a URL whose host is an IP address in a local network: that network's adapter | V | 
| `A VPN (V) with split tunnelling; A keeps the route to the internet.` | A | A; for a URL whose host is an IP address that the tunnel carries: V | A | 
| The same split-tunnel VPN while B has the route to the internet and A comes first in Windows' adapter order. | B | B; for a URL whose host is an IP address in a local network: that network's adapter | A | 

One Windows 11 25H2 computer with five network adapters; Edge 155, Firefox 157, WinHTTP and WinINet. A, B and C stand for three of its adapters, with the example addresses 192.0.2.10, 198.51.100.10 and 203.0.113.10; V is the adapter of a VPN made with Windows' built-in client (SSTP). Other setups and other VPN clients can give other answers. (source: lab, verified 2026-10-14)

## Chrome, Edge and Firefox follow the route to the internet; Windows follows the adapter order

- **Chrome and Edge** ask the system which local address it would use to reach 8.8.8.8 or
  2001:4860:4860::8888. Nothing is sent. Only when neither address has a route do they look
  up the computer's own name, and then routes towards the private ranges. They skip
  loopback addresses, use 169.254.x.x and fe80:: addresses only as a last resort, prefer
  IPv4, and return `127.0.0.1` when nothing is found. Adapter type and adapter order play
  no part. The destination of the request does not matter either.
- **Firefox** does the same with 8.8.8.8, with one difference. When the URL's host is an IP
  address, it uses the route towards that address, so two requests from the same page can
  get two different answers. With the global `pacUseMultihomedDNS = true` in the script, it
  first looks up the host name and uses the route towards the result. That costs a DNS lookup
  on every call.
- **Windows** (WinHTTP, and WinINet, which gave the same answers) did not follow the route in
  any test. With several addresses it returned the address of the first adapter in Windows'
  order, which is the order of the interface metric. It did so also when that adapter had no
  route to the internet at all.
- **pactester** (pacparser) returns the first IPv4 address of the computer's own name, or
  the address set with `pactester -c`.

No engine returned a 169.254.x.x address or `127.0.0.1` while the computer had a working
address. A file that compares `myIpAddress()` with address ranges should still expect
`127.0.0.1`, because Chrome, Edge and Firefox return it when they find nothing else.

## A VPN changes the answer differently in each engine

A VPN adds an adapter and changes the routes, and the engines react to different parts of that
change. In the test with Windows' built-in VPN client, a full tunnel moved every engine to the
VPN address: the browsers because the tunnel took the route to the internet, and Windows' own
engine because Windows raised the interface metric of all other adapters while the tunnel was
connected. With split tunnelling, the browsers kept the address of whichever adapter had the
route to the internet, while Windows' own engine kept the first adapter in its order. The two
were not always the same adapter, so one split-tunnel VPN gave two different answers on the
same computer. Firefox also returned the VPN address for a URL whose host was an IP address
inside the networks the tunnel carried. Windows by default sends the whole class A, B or C
network of the VPN address into the tunnel, so that can be more than the routes the VPN set up.
Other VPN clients set routes and metrics in their own way, so these results are examples, not
a rule for every VPN.

## Changing the interface metric changes the answer in Windows, not in the browsers

In the test, a lower interface metric for an adapter changed what WinHTTP and WinINet
returned at once. Chrome, Edge and Firefox kept returning the address of the adapter with
the route to the internet. Their answer changes only when the metric change also moves the
route to the internet to another adapter. That happens when two adapters have a default
gateway, because Windows adds the interface metric to the route metric.

## Windows 10 and 11 set the adapter order with the interface metric

Older Windows versions had an "Adapters and Bindings" tab (in `ncpa.cpl`, press Alt, then
Advanced, then Advanced Settings). Windows 10 and 11 no longer have it. The order now comes
from the interface metric, where a lower number comes first:

- **Settings dialog:** open the adapter's properties, then "Internet Protocol Version 4
  (TCP/IPv4)" (or Version 6), then Properties, Advanced. Clear "Automatic metric" and enter
  a number.
- **PowerShell:** `Get-NetIPInterface | Sort-Object InterfaceMetric` shows the order, and
  `Set-NetIPInterface -InterfaceAlias "Wi-Fi" -InterfaceMetric 5` changes it.
  `Set-NetIPInterface -InterfaceAlias "Wi-Fi" -AutomaticMetric Enabled` goes back to the
  automatic value.
- **Registry:** `HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{adapter GUID}\InterfaceMetric`.
  In the test, a value written there took effect only after the adapter was disabled and
  enabled again. A change with `Set-NetIPInterface` took effect at once.

The old binding order in `HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Linkage\Bind` (and
`Tcpip6\Linkage\Bind`) changed nothing in any engine: not at once, not after the adapters
were disabled and enabled again. After a restart of Windows, WinHTTP and WinINet still returned
the same address and listed the addresses in `myIpAddressEx()` in the same order. The automatic metric depends on
the link speed, so it can change when an adapter reconnects at another speed.

## pactester takes myIpAddress from the test machine's name

pactester (pacparser) works out the address from the name of the machine it runs on, so in a
test the answer depends on that machine's own setup, not on a user's laptop. Set the client
address explicitly in tests (`pactester -c 10.20.1.5`), or enter it as the client IP in the
[PAC file tester](https://findproxyforurl.net/check/) and compare the engine profiles.


## Engine notes

- chromium: Asks the system which local address it would use towards 8.8.8.8 and 2001:4860:4860::8888, without sending anything. Only without such a route does it look up the computer's own name, then routes towards 10.0.0.0, 172.16.0.0, 192.168.0.0 and fc00::. Skips loopback addresses, uses link-local addresses only as a last resort, prefers IPv4, and returns 127.0.0.1 when nothing is found. Adapter type and order play no part. (source: code, verified 2026-10-14)
- chromium: Edge 155 returned the address of the adapter with the route to the internet in every setup, for every destination, also when another adapter had a lower interface metric. With a full-tunnel VPN that was the VPN address, with split tunnelling the physical adapter's. (source: lab, verified 2026-10-14)
- chromium: The browser's own DNS client plays no part: the lookup of the computer's own name always asks the operating system, whether the built-in DNS client is on or off. (source: code, verified 2026-10-15)
- firefox: For a host that is an IP address, the local address of the route towards it; otherwise the route towards 8.8.8.8 (with pacUseMultihomedDNS = true, towards the resolved host). Without such a route: the computer's own name, then routes towards 192.168.0.1 and 10.0.0.1, then 127.0.0.1. Does not look at the adapter type. (source: code, verified 2026-10-14)
- firefox: Firefox 157 returned the address of the route to the internet for host names, and the address of the matching adapter for IP-address hosts in a local network. (source: lab, verified 2026-10-14)
- pacparser: The value set with setmyip() (pactester -c), else the first IPv4 address of the computer's own name; 127.0.0.1 when the name does not resolve. Routes and adapters are not looked at. (source: code, verified 2026-10-14)
- winhttp: Did not follow the route. With several addresses it returned the address of the adapter with the lowest interface metric, also when that adapter had no route to the internet. Never returned 169.254.x.x while another address existed. The service and the in-process mode gave the same answers. With a full-tunnel VPN from Windows' built-in client it returned the VPN address, because Windows raised the other adapters' interface metric while the tunnel was up; with split tunnelling it kept the first physical adapter. (source: lab, verified 2026-10-14)
- wininet: Same answers as WinHTTP in every setup (InternetGetProxyForUrl with an automatic configuration URL). (source: lab, verified 2026-10-14)

## Frequently asked questions

### Which address does myIpAddress() return on a computer with several network adapters?

It depends on the engine. Chrome, Edge and Firefox returned the address of the adapter with the route to the internet. Windows' own proxy engine (WinHTTP, WinINet) returned the address of the adapter with the lowest interface metric, even when that adapter had no route to the internet. pactester returns the first address of the computer's name. Measured on Windows 11 in October 2026; other setups can give other answers, so do not base routing decisions on it.

### Does myIpAddress() return the VPN address or the physical address?

It depends on the engine and on how the VPN sets routes and metrics. In a test with Windows' built-in VPN client, a full-tunnel VPN gave the VPN address in Chrome, Edge, Firefox and Windows' own engine. With split tunnelling the browsers returned the adapter with the route to the internet and Windows' own engine the first adapter in its order, which were not always the same. Do not base routing decisions on it.

### Does changing the interface metric change myIpAddress()?

In WinHTTP and WinINet it did, at once when changed with Set-NetIPInterface. In Chrome, Edge and Firefox it changes the answer only if it also moves the route to the internet to another adapter.

### Where is the network adapter binding order in Windows 10 and 11?

The "Adapters and Bindings" tab is gone. The order now comes from the interface metric, set in the adapter's IPv4 or IPv6 properties under Advanced (clear "Automatic metric"), with Set-NetIPInterface -InterfaceMetric, or in the registry under Tcpip\Parameters\Interfaces\{GUID}\InterfaceMetric. The old Tcpip\Linkage\Bind list had no effect on myIpAddress() in the test, also not after a restart.

### Why does myIpAddress return a different address in pactester than in Chrome?

pactester derives the address from the name of the machine running the test, while Chrome, Edge and Firefox use the address of the connection towards the internet. Set the expected address in tests with pactester -c, or enter it as the client IP in the tester at findproxyforurl.net/check/.

