---
title: Is your database port open to the internet?
description: A firewall change can expose a database port without breaking anything, and a closed SSH port stays quiet while the website is up. What open, closed and filtered mean from outside, why a CDN hostname answers on ports you never opened, and how to watch the ports that must be open and the ports that must be closed on one host.
canonical: https://watchfor.io/blog/is-your-database-port-open-to-the-internet
---

# Is your database port open to the internet?

2026-11-30 · WatchFor Team · Security · security, networking, tcp, monitoring

A firewall change can expose a database port without breaking anything, and a closed SSH port stays quiet while the website is up. What open, closed and filtered mean from outside, why a CDN hostname answers on ports you never opened, and how to watch the ports that must be open and the ports that must be closed on one host.

A firewall rule is edited during a deploy. A new service binds to `0.0.0.0`
instead of `127.0.0.1`. A cloud security group is copied from the test
environment, where port 5432 was open for testing. Each of these can put a
database or an admin port on the internet, and none of them breaks anything.
The site loads. The uptime check stays green. Nothing is logged as an error,
because nothing failed.

The opposite failure is just as quiet. After a change, SSH stops answering,
or the mail submission port does, while the website on 443 stays up. You find
out when the next deploy can't connect, or when mail starts piling up in a
queue somewhere.

Both are questions about which ports a host answers on, asked from outside.
This post covers the three answers a port can give, two traps that make a
port check pass when it should not (we ran into one on our own hostname), and
how the new WatchFor Port monitor checks a host against a list of ports that
must be open and a list of ports that must be closed.

## Three answers a port can give

To test a TCP port from outside, you try to open a connection and see what
comes back. There are three outcomes.

| State | What comes back | What it tells you |
| --- | --- | --- |
| **Open** | The connection is accepted (SYN-ACK). | Something listens on the port, and nothing on the way blocks it. |
| **Closed** | A reset (RST): the host refused. | The host is up and reachable. Nothing listens on the port, or a firewall rule rejects with a reset. |
| **Filtered** | Nothing before the timeout, or "host unreachable". | Something dropped the packet: a firewall or security group, a route that goes nowhere, or a host that is off. |

In client terms, closed is "connection refused" and filtered is "connection
timed out". The [connection refused](/blog/connection-refused) post covers
the client side of both.

### Filtered is not closed

A closed port is an answer. The host exists, the path to it works, and it
said no. A filtered port is the absence of an answer. From outside, a
firewall that drops packets and a server that is switched off look exactly
the same on that port.

That matters in both directions:

- For a port that **must be closed**, both are fine. Refused or dropped, the
  port can't be reached.
- For a port that **must be open**, both are failures, but they point at
  different fixes. Closed: the service is not listening. It crashed, it binds
  to localhost only, or the deploy moved it to another port. Filtered: look
  at the firewall, the security group, the route or the host itself.

### A must-be-closed policy passes on a dead host

Here is the first trap. Say the policy for a database server is "3306, 5432
and 6379 must be closed", and nothing else. The server goes down. Every port
in the policy is now filtered, filtered counts as closed, and the check
passes. It also passes if someone typed the wrong IP address, or if DNS now
points at an address where nothing answers.

"All closed" and "nobody home" give the same result unless the check also
asks whether the host answered at all: did at least one port accept the
connection or refuse it? Two ways to get that:

- Add one port that must be open, such as 22 or 443. If the host is down,
  that port fails.
- Alert when no port of the policy answered. In WatchFor this is the optional
  **Host not responding** rule.

There is one kind of host where neither works, and it comes up below: a host
that answers nobody but your CDN.

## What we found on our own hostname

In our demo organization, Acme, we set up a Port monitor for `watchfor.io`,
our own website. The policy: 80 and 443 must be open, and 16 ports must be
closed: FTP, SSH, Telnet, SMTP, POP3, IMAP, SMB, the common databases and
caches, RDP and VNC. Then we added 8443 to the must-be-closed list.

The first check after the change opened a critical incident: *Port 8443
(https-alt) is open and must be closed.* Of the 19 ports, 80, 443 and 8443
accepted the connection. The other 16 gave no answer at all.

![The Acme Port monitor "Edge firewall — watchfor.io" marked Down: the Port status card says 1 port differs of 19, 1 open that must be closed; the Scan details card shows 3 open, 0 closed and 16 filtered at address 172.67.73.26, with the last scan taking 3 seconds; below, the policy panel reads "Must be closed, but is open: Port 8443 (https-alt) is open and must be closed"](/blog/is-your-database-port-open-to-the-internet-hero.webp)

The address on the card explains it. That check connected to `172.67.73.26`,
and an earlier one to `104.26.15.72`. Neither is our server. Both sit in the
address ranges Cloudflare publishes for its network
(`172.64.0.0/13` and `104.24.0.0/14`, on
[cloudflare.com/ips](https://www.cloudflare.com/ips/)), because `watchfor.io`
is proxied by Cloudflare. Every connection the check made to that hostname
went to Cloudflare's edge. Our own firewall never saw any of them.

Cloudflare documents this on its
[network ports page](https://developers.cloudflare.com/fundamentals/reference/network-ports/).
By default its proxy takes HTTP on ports 80, 8080, 8880, 2052, 2082, 2086 and
2095, and HTTPS on 443, 2053, 2083, 2087, 2096 and 8443. The same page says
that "ports other than `80` and `443` will be open so that Cloudflare can
serve traffic for other customers on these ports", and that tools like Netcat
and security scanners can report them as open. Cloudflare does offer a rule
that blocks non-standard ports, and the page says it blocks at the
application layer (layer 7). That is above TCP: the connection is accepted
before the rule ever sees a request, so a TCP check still sees the port as
open. Our policy named only 8443 of those ports, so our run says nothing about
the others. The list above is Cloudflare's, not our measurement.

Other CDNs and load balancers have their own listeners. The general point:
**a port check on a hostname tests whatever answers at the address the name
resolves to.** If that address is a CDN's, your origin firewall can be
perfect while the public name answers on ports you never opened. It does not
work the other way round either. A clean result on the CDN name says nothing
about the origin behind it.

### Check the origin and the public name separately

For a site behind a CDN or a load balancer, that means two monitors.

**The origin's address, for the firewall policy.** Put the IP address of the
server, or of the load balancer in front of it, in the target, not the public
name. This is where an exposed database port would show up. If the origin
accepts web traffic only from your CDN's address ranges, then from any other
network 443 is filtered too. Put 443 in this monitor's must-be-closed list.
That turns "is the origin still locked to the CDN?" into a check that fails
on the first run after someone opens it to the world.

This is the kind of host where the dead-host trap has no fix from outside.
An origin that drops everything except the CDN looks the same whether it is
up or down: every port is filtered. Host not responding can't tell the two
apart, so leave it off for such a host. If your firewall rejects with a reset
instead of dropping, the refused ports do prove the host is there. Otherwise,
whether the origin is up is a job for an [HTTP monitor](/http-monitoring) on
the public URL, which goes through the CDN.

**The public name, for what the world sees.** Here 80 and 443 must be open.
The CDN's own listeners belong in neither list, because they answer whatever
you configure. A must-be-closed list of database ports still earns its place:
the check resolves the name on every run, so if someone switches the DNS
record from proxied to DNS-only, the same monitor starts checking the origin
directly. An open database port then fails it on the first check, and the
monitor page shows the new address it checked.

One more detail: when a name resolves to several addresses, each check
connects to one of them. To hold a firewall policy on three servers, give
each server's address its own monitor.

## How the Port monitor checks a host

The Port monitor is new in WatchFor this week. It holds a policy for one host,
a hostname or an IP address without a port, and two lists:

- **Must be open:** ports that must accept a connection.
- **Must be closed:** ports that must not.

Both lists take single ports and ranges, such as `22, 80, 443` or
`8000-8100`. A port in both lists must be open, so closed `1-100` with open
`22, 80` reads: of ports 1 to 100, only 22 and 80 may answer. The form counts
the distinct ports of both lists against your plan's limit per monitor, and
every port of a range counts.

![Creating a Port monitor in the Acme organization: the target db1.acme-shop.example, 22 in the must-be-open list with Web, SSH and Mail presets below it, 3306, 5432, 6379, 9200, 11211 and 27017 in the must-be-closed list with Databases, Remote desktop and Telnet / FTP presets, and the line "Checks 7 ports · your plan allows 100 per monitor"](/blog/is-your-database-port-open-to-the-internet-form.webp)

Each check opens a plain TCP connection to every port of the policy. There is
no SYN scan and there are no raw packets, so each port costs the host what one
client connection costs, and the check keeps at most 25 connections to the
host open at a time. A port that does not answer within the timeout, 3
seconds by default, is filtered. Our 19-port run took 3 seconds in total: the
16 silent ports waited out their timeouts in parallel.

A port that must be open and isn't gets a second try within the same check
before it counts, so one lost packet does not open an incident. Then three
rules decide what becomes an incident:

| Rule | Default | Fires when |
| --- | --- | --- |
| **Forbidden port open** | On, critical | A must-be-closed port accepts a connection. Fires on the first check that finds it. |
| **Required port not open** | On, critical | A must-be-open port is closed or filtered on three checks in a row. |
| **Host not responding** | Off, warning | No port of the policy answered at all, neither open nor refused. |

The difference in timing is deliberate. A required port can flap for a few
seconds while a service restarts, so that rule waits for three checks. A
forbidden port that accepts a connection is reachable from the first check
that sees it, and waiting would only keep it reachable longer. An incident
closes after three healthy checks in a row. A separate status rule covers a
check that could not run at all, for example because the hostname did not
resolve.

The incident says what was found and how far that goes. For our run: nothing
is down, a port that must be closed accepts connections, and WatchFor reports
that the port accepted a connection, not what runs behind it.

![The incident for the Acme Port monitor: What happened says nothing is down and a port that must be closed accepts connections; Diagnosis reads Forbidden port open, critical; Expected says no port in the must-be-closed list should accept a connection; Detected reads "Port 8443 (https-alt) is open and must be closed"; the activity timeline shows the incident opened on the first check, a notification sent, and that it closes after 3 healthy checks in a row](/blog/is-your-database-port-open-to-the-internet-incident.webp)

For every open port the monitor page shows the connect time, the usual service
for that port number and a banner: the first line the port sends on its own,
such as an SSH or SMTP greeting. HTTP and TLS servers wait for the client to
speak first, so 80 and 443 show no banner. The service label comes from the
port number only. Port 3306 is labelled mysql whatever actually listens there.

![The same monitor with every port as expected, before 8443 was added: As expected, all 18 ports checked; a table lists 80 (http) and 443 (https), each expected open and open, with connect times of 4 and 7 ms and no banner; below it, the 16 must-be-closed ports that gave no answer: 21-23, 25, 110, 143, 445, 1433, 3306, 3389, 5432, 5900, 6379, 9200, 11211 and 27017](/blog/is-your-database-port-open-to-the-internet-healthy.webp)

A few more things to know before you add one:

- **Every 5 minutes at the fastest.** One check is a connection to every
  port of the policy.
- **From WatchFor's own network,** not from the cloud probe locations, so
  there are no locations to pick. Connecting to many ports of one host from a
  cloud provider's address draws abuse reports. A firewall that answers
  differently by source address is seen as WatchFor's network sees it.
- **You confirm that you own the host or have permission to check its
  ports.** A Port monitor can't be saved without it, the confirmation is asked
  for again when the target changes, and the Activity Log records who gave it
  and when.
- **Plans:** 20 ports per monitor on Starter, 50 on Pro, 100 on Business and
  250 on Enterprise. The Free plan has no Port monitors. A Port monitor counts
  as one monitor, however many ports it checks.
- **Status pages** show these incidents in generic wording and never say which
  ports of a host are open.

## What it is not

- **Not a port scanner.** It checks the ports you list and nothing else. A
  service that starts listening on a port you didn't list is not found. "Of
  1-1024 only 22 and 443" is 1,024 ports, more than any plan allows per
  monitor. A periodic full scan of your own hosts with a tool such as nmap is
  the right job for that. A Port monitor is for the ports you already know
  matter, every few minutes.
- **No service fingerprinting.** It does not identify the software behind a
  port.
- **No vulnerability testing.** An open port is reported as open, not as
  vulnerable or safe.
- **TCP only.** UDP ports are not checked. For one UDP service, use
  [UDP monitoring](/udp-monitoring).

## A starting policy

For a server that answers web traffic directly, with no CDN in front, this
fits the Starter plan's 20 ports with room to spare:

```text
Target:          203.0.113.10
Must be open:    80, 443
Must be closed:  21, 23, 1433, 2375, 3306, 3389, 5432, 5900,
                 6379, 9200, 10250, 11211, 27017
```

That is 15 ports: FTP and Telnet, the common databases and caches (MSSQL,
MySQL, PostgreSQL, Redis, Elasticsearch, Memcached, MongoDB), the Docker API
on 2375, the kubelet on 10250, and RDP and VNC. Then decide about 22: must be
open if you reach the server over SSH from anywhere, must be closed if SSH
only comes in through a VPN or a bastion host. If a CDN is in front, move 80
and 443 to the origin monitor's must-be-closed list, as described above.

To see whether one port answers from outside right now, the free
[Port Checker](/port-checker) tests a single TCP port once, with no account.
To keep checking a whole policy, create a [Port monitor](/port-monitoring);
the [docs](/docs/monitors/network#port-monitor) list every setting and rule.

---

Canonical page: https://watchfor.io/blog/is-your-database-port-open-to-the-internet · All articles: https://watchfor.io/blog/all.md · Site guide: https://watchfor.io/llms.txt
