sodcalculator

10 Tech How-To

ERR_UNSAFE_PORT Error in Chrome: Fixes

Guide 10-12440 · Updated · Step by step

The “ERR_UNSAFE_PORT” error in Chrome appears when you try to open a website or local server that uses a port number Chrome has blocked for security reasons. The fix is to use a different port number, or to launch Chrome with a special flag that allows the blocked port. This guide explains why Chrome blocks certain ports, how to fix the error, and how to avoid it in the future.

What Causes ERR_UNSAFE_PORT

Chrome maintains a hardcoded list of port numbers that it refuses to connect to. These are ports that are commonly associated with sensitive services or known security risks, such as port 21 (FTP), 25 (SMTP), 110 (POP3), and 143 (IMAP). The list also includes ports used by protocols that could be abused for cross-protocol scripting attacks, like port 6000 (X11) and port 6666 (IRC). When you attempt to visit a URL like http://localhost:6000, Chrome blocks the request and shows the error page.

This is not a bug—it is a deliberate security measure. The blocked ports are ones where a malicious website could potentially interact with a local service running on your machine, or where unencrypted traffic could expose sensitive data. Firefox and Safari have similar lists, though they are not identical to Chrome’s.

How to Fix ERR_UNSAFE_PORT

The simplest and safest fix is to change the port number on the server or application you are trying to access. If you are running a local development server, pick a port that is not on Chrome’s blocklist—anything above 1024 and not in the list will work. For example, instead of http://localhost:6000, use http://localhost:8080 or http://localhost:3000.

If you cannot change the port (for example, you are testing a legacy application), you can launch Chrome with the --explicitly-allowed-ports flag. This tells Chrome to allow a specific port despite the blocklist. Here is how to do it on each operating system:

  1. Windows: Right-click the Chrome shortcut, select Properties, and in the Target field add --explicitly-allowed-ports=6000 at the end (after the existing path). Click OK and relaunch Chrome.
  2. macOS: Open Terminal and run open -a "Google Chrome" --args --explicitly-allowed-ports=6000.
  3. Linux: In a terminal, run google-chrome --explicitly-allowed-ports=6000 (or chromium if you use Chromium).

You can list multiple ports separated by commas, like --explicitly-allowed-ports=6000,6666. Note that this flag only works for the current Chrome session; you need to set it every time you launch Chrome.

Chrome’s Blocked Port List

Chrome’s blocklist is based on the Chromium source code and includes the following ports (this is not exhaustive):

  • 1, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 37, 42, 43, 53, 77, 79, 87, 95, 101, 102, 103, 104, 109, 110, 111, 113, 115, 117, 119, 123, 135, 139, 143, 179, 389, 465, 512, 513, 514, 515, 526, 530, 531, 532, 540, 548, 554, 556, 563, 587, 601, 636, 989, 990, 993, 995, 1719, 1720, 1723, 2049, 3659, 4045, 5060, 5061, 6000, 6566, 6665, 6666, 6667, 6668, 6669, 6697, 10080

These ports are blocked because they are associated with protocols like FTP, SSH, Telnet, SMTP, DNS, and IRC, which are either unencrypted or could be used for malicious purposes. If your server uses one of these ports, you will see the error.

How to Choose a Safe Port for Development

When setting up a local development server, choose a port that is not on the blocklist and is not commonly used by other services. Good choices include:

  • 3000 (React, Node.js default)
  • 5000 (Flask, some Node.js setups)
  • 8000 (Python’s SimpleHTTPServer)
  • 8080 (common alternative to 80)
  • 8888 (Jupyter Notebook, some proxies)

Avoid ports below 1024 unless you are running as root/administrator, as they are reserved for system services. Also avoid ports that are commonly used by other software on your machine, like 3306 (MySQL) or 5432 (PostgreSQL), to prevent conflicts.

Common Problems and Misconceptions

One common misconception is that the error only happens on localhost. In fact, it can happen on any website that uses a blocked port, although it is rare because most public websites use port 80 or 443. Another misconception is that the error is caused by a firewall or antivirus. While those can cause similar connection errors, ERR_UNSAFE_PORT is specifically Chrome’s blocklist.

If you see the error on a website that you trust, you can use the flag method to access it, but be cautious—the blocklist exists for a reason. If you are developing an application that must run on a blocked port (for example, you are building an FTP client), consider using a different port for testing and only enable the flag when necessary.

Alternatives to Chrome

If you cannot change the port and do not want to use the flag, you can use a different browser for that specific site. Firefox and Edge do not have the same blocklist, so they will often load the page without issue. However, be aware that the site may still be insecure if it uses an unencrypted protocol. For development, you can also use a proxy or a port forwarding tool like ngrok to expose a local server on a standard port.

Frequently Asked Questions

Is ERR_UNSAFE_PORT a virus or malware?

No, it is a standard Chrome error message. It appears when the browser refuses to connect to a port on its blocklist. It does not indicate that your computer is infected, though you should always be cautious when visiting unknown sites.

Can I disable the port blocklist permanently?

There is no official way to disable it permanently in Chrome’s settings. The --explicitly-allowed-ports flag only works for the current session. You can create a shortcut or script that launches Chrome with the flag every time, but it is not a persistent setting.

Why is port 6000 blocked?

Port 6000 is used by the X11 display server, which is a graphical windowing system for Unix-like operating systems. Chrome blocks it to prevent a malicious website from interacting with a local X11 server, which could allow screen capture or input injection.

What if I need to use port 21 for an FTP server?

Chrome does not support FTP anymore (it was removed in version 88), so you would need to use an FTP client like FileZilla. If you are trying to access an FTP server via HTTP (which is not standard), you should use a different port or a different protocol.

Does this error affect other browsers?

Firefox has a similar blocklist, but it is shorter and can be overridden by changing the network.security.ports.banned.override preference in about:config. Edge, being Chromium-based, has the same blocklist as Chrome. Safari has a limited blocklist as well.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →