---
title: "ping( target, [options] ) | Grafana k6 documentation"
description: "Send ICMP echo requests synchronously"
---

# ping( target, \[options] )

Sends ICMP echo requests (pings) to the specified target.

## Signature

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
ping(target, options)
```

## Parameters

Expand table

| Parameter | Type                                                                  | Description                          |
|-----------|-----------------------------------------------------------------------|--------------------------------------|
| target    | string                                                                | Hostname or IP address to ping.      |
| options   | [PingOptions](/docs/k6/latest/javascript-api/k6-x-icmp/ping-options/) | Optional ping configuration options. |

## Returns

Expand table

| Type    | Description                                                                                                    |
|---------|----------------------------------------------------------------------------------------------------------------|
| boolean | Returns `true` if the number of successful pings is greater than or equal to the threshold, otherwise `false`. |

## Example

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
import { ping } from "k6/x/icmp"

export default function () {
  const host = "8.8.8.8"

  console.log(`Pinging ${host}:`);

  if (ping(host)) {
    console.log(`Host ${host} is reachable`);
  } else {
    console.error(`Host ${host} is unreachable`);
  }
}
```
