IsLocalHost

Determine whether a given string value represents a loopback IP address, like localhost, 127.0.0.1 or ::1.

Method Signature

IsLocalHost(ip=[string])

Arguments

Argument
Type
Required
Description
Default

ip

string

true

String representing the IP address to test.

Examples

Is 127.0.0.1 localhost

Run Example

isLocalHost( "127.0.0.1" );

Result: true

Is ::1 localhost

Test the IPv6 Loopback address. IPv6 only has one loopback address.

Run Example

isLocalHost( "::1" );

Result: true

Is 127.8.8.8 localhost

IPv4 network standards reserve the entire 127.0.0.0/8 address block for loopback networking purposes however they are not usually mapped to localhost by default.

Run Example

isLocalHost( "127.8.8.8" );

Result: true

Is 8.8.8.8 localhost

Not a localhost IP.

Run Example

isLocalHost( "8.8.8.8" );

Result: false

Additional Examples

ip = "127.0.0.1";
writeDump( islocalhost( ip ) ); // true
writeDump( islocalhost( GetLocalHostIP() ) );
 // true

Last updated

Was this helpful?