Celeb Glow
updates | March 06, 2026

How to fix ERR_UNSAFE_PORT error on Chrome when browsing to unsafe ports

I'm getting this error when connecting to a web server on port 6666 ():

Error 312 (net::ERR_UNSAFE_PORT): Unknown error.

Is there an easy way to resolve this without rebuilding Chrome from source?

7 Answers

On Windows:

Right Click on Chrome shortcut >> Properties >>

Then Append --explicitly-allowed-ports=xxx to shortcut target

Example:

C:\Documents and Settings\User\Local Settings\Application Data\Google\Chrome\Application\chrome.exe --explicitly-allowed-ports=6666

Resource from here

6

You may be able to turn this off in Google Chrome, but you do so at your own risk. There is actually a good security reason why Chrome blocks these ports: Basically you open your browser up to being an open proxy for attackers to use to attack other services on your network.

For more information: Why does Chrome consider some ports unsafe?

5

On Mac you can create an app launching Chrome with parameters mentioned in other answers using Automator built-in Apple application:

  1. Launch Automator

  2. As "Type of document" choose "Application"

  3. Add action "Run shell script"

  4. Replace placeholder cat script in this action with:

/Applications/Google\ Chrome --explicitly-allowed-ports=5000,6000,7000

  1. Save the created app as something like "Google Chrome with allowed unsafe ports" in your Application folder

  2. Use this new app instead of Google Chrome directly

  3. (optional) Replace default icon of the created "app" - Automator's robot - with Chrome's using this method (note: upvote that answer if you like it!)

Source:

image

1

As subanki said, you've got to add the -explicitly-allowed-ports option to your Chrome startup command.

In Ubuntu you can do this (as root) by editing the "google-chrome" script under your Chrome installation folder

You can get the directory by typing:

ls -la /usr/bin | grep chrome

Then, edit the "google-chrome" file adding the mentioned switch to the EXEC line:

exec -a "$0" "$HERE/chrome" "-explicitly-allowed-ports=6000" "$@"

Just change "6000" with the comma separated values you might need (example: -explicitly-allowed-ports=5000,6000,7000)

NOTE: for UNIX, the switch does NOT start with "--", it does with a single "-"

1

For Mac:

/Applications/Google\ Chrome --explicitly-allowed-ports=5000,6000,7000

for ports 5000, 6000, and 7000.

You can explicitly allow ports just like the other answers state, but for most cases the problem is easier to solve by just not using the restricted ports:

const int kRestrictedPorts[] = { 1, // tcpmux 7, // echo 9, // discard 11, // systat 13, // daytime 15, // netstat 17, // qotd 19, // chargen 20, // ftp data 21, // ftp access 22, // ssh 23, // telnet 25, // smtp 37, // time 42, // name 43, // nicname 53, // domain 69, // tftp 77, // priv-rjs 79, // finger 87, // ttylink 95, // supdup 101, // hostriame 102, // iso-tsap 103, // gppitnp 104, // acr-nema 109, // pop2 110, // pop3 111, // sunrpc 113, // auth 115, // sftp 117, // uucp-path 119, // nntp 123, // NTP 135, // loc-srv /epmap 137, // netbios 139, // netbios 143, // imap2 161, // snmp 179, // BGP 389, // ldap 427, // SLP (Also used by Apple Filing Protocol) 465, // smtp+ssl 512, // print / exec 513, // login 514, // shell 515, // printer 526, // tempo 530, // courier 531, // chat 532, // netnews 540, // uucp 548, // AFP (Apple Filing Protocol) 554, // rtsp 556, // remotefs 563, // nntp+ssl 587, // smtp (rfc6409) 601, // syslog-conn (rfc3195) 636, // ldap+ssl 989, // ftps-data 990, // ftps 993, // ldap+ssl 995, // pop3+ssl 1719, // h323gatestat 1720, // h323hostcall 1723, // pptp 2049, // nfs 3659, // apple-sasl / PasswordServer 4045, // lockd 5060, // sip 5061, // sips 6000, // X11 6566, // sane-port 6665, // Alternate IRC [Apple addition] 6666, // Alternate IRC [Apple addition] 6667, // Standard IRC [Apple addition] 6668, // Alternate IRC [Apple addition] 6669, // Alternate IRC [Apple addition] 6697, // IRC + TLS 10080, // Amanda
};

Source

So instead of 6666 you could use 6060 and you wouldn't have this problem.

1

Here is the correct answer for those of you who are developers using node.js as a web server: change the port you are using to host your web pages.

For example
if you typed into command line node index.js & pressed enter,
if it started running on port 22 for 80 http request,
when you visit the website at port 22,
the chrome browser with throw this error page.,br> keyword UNSAFE PORT means port needs to match the content.