Skip to main content
https://github.com/opencve/opencve/workflows/Tests/badge.svg https://badge.fury.io/py/whatportis.svg https://img.shields.io/badge/python-3.6%2B-blue.svg https://img.shields.io/github/license/ncrocfer/whatportis.svg https://img.shields.io/badge/code%20style-black-000000.svg

It’s a common task to search the default port number of a service. Some ports are available in the /etc/services file, but the list is not complete and this solution is not portable.

Whatportis is a simple tool that downloads the Iana.org database and uses it to explore the official list of ports.

Usage

Whatportis allows you to find what port is associated with a service:

$ whatportis redis
+-------+------+----------+---------------------------------------+
| Name  | Port | Protocol | Description                           |
+-------+------+----------+---------------------------------------+
| redis | 6379 |   tcp    | An advanced key-value cache and store |
+-------+------+----------+---------------------------------------+

Or, conversely, what service is associated with a port number:

$ whatportis 5432
+------------+------+----------+---------------------+
| Name       | Port | Protocol | Description         |
+------------+------+----------+---------------------+
| postgresql | 5432 | tcp, udp | PostgreSQL Database |
+------------+------+----------+---------------------+

You can also search a pattern without knowing the exact name by adding the --like option:

$ whatportis mysql --like
+----------------+-------+----------+-----------------------------------+
| Name           |  Port | Protocol | Description                       |
+----------------+-------+----------+-----------------------------------+
| mysql-cluster  |  1186 | tcp, udp | MySQL Cluster Manager             |
| mysql-cm-agent |  1862 | tcp, udp | MySQL Cluster Manager Agent       |
| mysql-im       |  2273 | tcp, udp | MySQL Instance Manager            |
| mysql          |  3306 | tcp, udp | MySQL                             |
| mysql-proxy    |  6446 | tcp, udp | MySQL Proxy                       |
| mysqlx         | 33060 |   tcp    | MySQL Database Extended Interface |
+----------------+-------+----------+-----------------------------------+

Installation

$ pip install whatportis

Database Sync

Whatportis uses a local JSON file (~/.whatportis_db.json) to explore the list of ports. The first usage will create it for you, then you can use the --update option to synchronize it :

$ whatportis --update
Previous database will be updated, do you want to continue? [y/N]: y
Downloading https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.csv...
Populating database...
14145 ports imported.

JSON output

You can display the results as JSON, using the --json option :

$ whatportis 5432 --json
[
    {
        "name": "postgresql",
        "port": "5432",
        "protocol": "tcp, udp",
        "description": "PostgreSQL Database"
    }
]

REST API

Whatportis can also be started as a RESTful API server. This feature is not enabled by default, you must install an extra package :

$ pip install whatportis[server]
$ whatportis --server localhost 8080
 * Serving Flask app "whatportis.server" (lazy loading)
 * Environment: prod
 * Debug mode: off
 * Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)

The endpoints are /ports for the whole list (can be long) and /ports/<search> to search a specific port :

$ curl http://127.0.0.1:8080/ports/3306
{"ports":[{"description":"MySQL","name":"mysql","port":"3306","protocol":"tcp, udp"}]}

$ curl http://localhost:8080/ports/redis
{"ports":[{"description":"An advanced key-value cache and store","name":"redis","port":"6379","protocol":"tcp"}]}

You can use the ?like parameter to search a pattern.

Metadata

Release files for whatportis 0.8.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for whatportis 0.8.2
File Size Uploaded
whatportis-0.8.2.tar.gz 20.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for whatportis 0.8.2
File Interpreter ABI Platform
whatportis-0.8.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.0 kB

Release files / whatportis-0.8.2.tar.gz

Download URL whatportis-0.8.2.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4171e66cf9ec503b30be713fb6bd348e04feb3ebb189c40f77e512684242a8a6
BLAKE2b-256 checksum
How to use checksums
cec5995a66955475efb23c71d4b344bb6a5210d2d53048298079ea8b2d959801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.5.0.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.1

Release files / whatportis-0.8.2-py3-none-any.whl

Download URL whatportis-0.8.2-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20703c7062b92828a5b3d5e708cda948a5b8240a0f236031da0e8c1a38903ad4
BLAKE2b-256 checksum
How to use checksums
ccfc9c75a97572b8da8cf979679c07060f097e5a0aee47df57a8b318a79ba7df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.5.0.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.1

Release history Release notifications | RSS feed

This release

0.8.2 This release

2 release files

0.8.1

2 release files

0.8

2 release files

0.7

2 release files

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page