# Port Scanner (`onescales/port-scanner`) Actor

Scan hundreds of hosts for open TCP ports in one run. Get open ports, detected services, and versions as CSV, JSON, or Excel.

- **URL**: https://apify.com/onescales/port-scanner.md
- **Developed by:** [One Scales](https://apify.com/onescales) (community)
- **Categories:** Developer tools, Automation, Other
- **Stats:** 4 total users, 4 monthly users, 100.0% runs succeeded, 4 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

**Scan hosts for open ports in bulk with a single click.** Give it a list of hostnames, IPs, or URLs and it returns a clean table showing which TCP ports are open on each one, what service is listening, and how much of the requested range was covered. Using Nmap for port scan.

No sign-ups, no API keys, no third-party services required. Paste your targets, click Start, and download your results.

> ⚖️ **Only scan hosts you own or have explicit permission to scan.** Unauthorized port scanning may be illegal in your jurisdiction. Loopback, private, and reserved IP addresses are blocked automatically.

| Field | Example |
|-------|---------|
| **Target** | scanme.nmap.org |
| **Resolved IP** | 45.33.32.156 |
| **Open Ports** | 2 |
| **Open Port List** | 22 (ssh), 80 (http) |
| **Ports Scanned** | 1000 |
| **Ports Requested** | 1000 |
| **Complete** | true |
| **Duration (ms)** | 875 |
| **Status** | success |

***

### Features

**Bulk Scanning**
Scan hundreds of hosts in one run. Six targets are scanned in parallel, and every result lands in one exportable table.

**Accurate Open-Port Detection**
Discovery uses a direct TCP-connect sweep with precise per-port timeouts. Open ports are always trustworthy — even when a scan is cut short.

**Honest Partial Results**
If a host is slow or heavily filtered and the time budget runs out, you get everything that was actually probed plus a `complete: false` flag and a warning explaining exactly what was and wasn't covered. No silently truncated results.

**Smart Port Ordering**
Well-known ports (80, 443, 22, and friends) are probed first, so even a partial scan surfaces the ports that matter most.

**Optional Service & Version Detection**
Turn on version detection to run an `nmap -sV` pass against the open ports only, identifying the software and version behind each one.

**Flexible Port Selection**
Use a range (`1-1000`), a specific list (`22,80,443`), or leave it blank to scan the most common ports automatically.

**Safe by Default**
Private, loopback, reserved, and multicast addresses are refused before any packet is sent.

**Per-Target Error Handling**
A host that fails to resolve doesn't kill the run — it's reported in its own row with a plain-English reason.

***

### Use Cases

**Security Auditing**
Confirm that only the ports you intend to expose are actually reachable from the public internet.

**Infrastructure Inventory**
Map what's listening across your servers, staging boxes, and cloud instances in one pass.

**Firewall Verification**
Validate that firewall and security-group rules behave the way you configured them.

**Pre-Migration Checks**
Verify a new host is serving on the right ports before cutting traffic over to it.

**Vendor & Partner Assessment**
Check the exposed surface of infrastructure you're responsible for or authorized to review.

**Uptime & Service Monitoring**
Confirm critical services (web, SSH, database, mail) are up and accepting connections across a fleet.

**Shadow IT Discovery**
Find forgotten admin panels, dev servers, and databases exposed on non-standard ports.

***

### Input

#### UI

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| **Targets (Hostnames / IPs / URLs)** | array | — | One or more hosts to scan. Full URLs are reduced to their hostname automatically. |
| **Ports** | string | 1000 common ports | A range like `1-1000`, a list like `22,80,443`, or leave blank. |
| **Scan Type** | select | `tcp_connect` | Opens a full TCP connection, the same way a browser would. |
| **Timeout (seconds per target)** | integer | `30` | Seconds allowed per target, 5–60. |
| **Detect Service Versions** | boolean | `false` | Runs an `nmap -sV` pass on open ports. Adds several seconds per target. |

Paste targets in any format — the actor cleans them up:

```
scanme.nmap.org
https://www.example.com/some/path?query=1
45.33.32.156
example.org:8080
```

Protocol (`https://`), `www.`, paths, ports, and query strings are all stripped automatically.

#### JSON

```json
{
  "targets": [
    "scanme.nmap.org",
    "example.com"
  ],
  "ports": "22,80,443",
  "scanType": "tcp_connect",
  "timeout": 30,
  "versionDetection": false
}
```

***

### Output

#### UI

Results appear as a table you can export to CSV, JSON, or Excel directly from the Apify console.

| Target | Resolved IP | Open Ports | Open Port List | Ports Scanned | Ports Requested | Complete | Duration (ms) | Status |
|--------|-------------|------------|----------------|---------------|-----------------|----------|---------------|--------|
| scanme.nmap.org | 45.33.32.156 | 2 | 22 (ssh), 80 (http) | 1000 | 1000 | true | 875 | success |

#### JSON

```json
{
  "target": "scanme.nmap.org",
  "resolvedIp": "45.33.32.156",
  "scanType": "tcp_connect",
  "durationMs": 875,
  "complete": true,
  "portsRequested": 1000,
  "portsScanned": 1000,
  "openPortCount": 2,
  "openPorts": "22 (ssh), 80 (http)",
  "openPortsDetail": [
    {
      "port": 22,
      "protocol": "tcp",
      "state": "open",
      "service": "ssh",
      "version": "OpenSSH 6.6.1p1"
    },
    {
      "port": 80,
      "protocol": "tcp",
      "state": "open",
      "service": "http",
      "version": "Apache httpd 2.4.7"
    }
  ],
  "closedOrFilteredCount": 998,
  "warning": null,
  "status": "success"
}
```

***

### Support

**Need help or want a feature added?**

[Contact Support — Fill out this quick form](https://docs.google.com/forms/d/e/1FAIpQLSfsKyzZ3nRED7mML47I4LAfNh_mBwkuFMp1FgYYJ4AkDRgaRw/viewform?usp=dialog)

We respond quickly and are happy to add new output fields, scan options, or custom integrations.

***

*Built with care by One Scales Inc.*

***

`port scanner` `port scan` `open ports` `tcp port scanner` `scan ports` `nmap` `open port check` `service detection` `network scanner` `port check` `host port scan` `security scan` `banner grab` `ssh port check` `bulk port scanner` `firewall check` `infrastructure` `security audit` `network` `tcp`

# Actor input Schema

## `targets` (type: `array`):

Enter one or more hostnames or IP addresses to scan. Full URLs are accepted and will be reduced to their hostname. Examples: scanme.nmap.org, 45.33.32.156, https://example.com

## `ports` (type: `string`):

Which ports to check. Use a range like '1-1000', a comma-separated list like '22,80,443', or leave this empty to automatically check the 1000 most commonly used ports.

## `scanType` (type: `string`):

How to probe each port. The only supported value is 'tcp\_connect', which opens a full TCP connection — the same way a browser or app would.

## `timeout` (type: `integer`):

How many seconds each target's scan is allowed to run before giving up. Must be between 5 and 60. Open ports found before the cutoff are always accurate; a partial scan is flagged with a warning.

## `versionDetection` (type: `boolean`):

Run a second nmap pass (-sV) on the open ports only, to identify the software and version behind each one. Off by default because it adds several seconds per target — leave it off for bulk runs, turn it on for small target lists where you need version detail.

## Actor input object example

```json
{
  "targets": [
    "scanme.nmap.org"
  ],
  "ports": "1-1000",
  "scanType": "tcp_connect",
  "timeout": 30,
  "versionDetection": false
}
```

# Actor output Schema

## `scanResults` (type: `string`):

All targets with their resolved IP, open ports, detected services and versions, ports scanned, and completion status

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "targets": [
        "scanme.nmap.org"
    ],
    "ports": "1-1000",
    "timeout": 30
};

// Run the Actor and wait for it to finish
const run = await client.actor("onescales/port-scanner").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "targets": ["scanme.nmap.org"],
    "ports": "1-1000",
    "timeout": 30,
}

# Run the Actor and wait for it to finish
run = client.actor("onescales/port-scanner").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "targets": [
    "scanme.nmap.org"
  ],
  "ports": "1-1000",
  "timeout": 30
}' |
apify call onescales/port-scanner --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,onescales/port-scanner"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/8sMgVnXswu9waAcua/builds/Qp0LdkdL5IBLPEKoL/openapi.json
