79

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

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

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

69

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

  • 1
    I missed this answer, thanks. I opened a separate question to understand which ports are safe/blocked by default: superuser.com/questions/188058/… – ripper234 Sep 13 '10 at 12:36
  • 2
    This answer is excellent... for Windows. It won't solve the problem for (for example) Mac. – Chris R May 3 '12 at 17:23
  • @ChrisR: Why? Does the --explicitly-allowed-ports switch not exist for Mac? – Dennis May 3 '12 at 17:35
  • 2
    Adding command line flags on the mac is a pain in the ass; if you add them to the app bundle they often get nuked in upgrades. – Chris R May 3 '12 at 17:39
  • @ChrisR: You should consider adding this to your question. – Dennis May 3 '12 at 17:44
18

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?

  • 1
    Why just making an HTTP request on a non standard port it is said to "open" the browser to being an open proxy to attack services in local network? Open how?? – jj_ Jul 22 '16 at 19:59
  • If it is left unchecked then any malicious code can make request to URLs with arbitrary ports. It might not be an optimal solution but by blocking other ports you are only leaving attackers with 80 & 443 to exploit. – Willa Jan 23 '17 at 14:39
  • the referenced link is now dead – Jeff Puckett Jun 13 '17 at 15:41
  • Link is now dead. Wayback Machine: web.archive.org/web/20170216040700/https://jazzy.id.au/2012/08/… (suggested edit) – Nulano Jun 26 '17 at 17:54
  • Link is now fixed on the server (server had an incorrectly configured timezone causing it to serve the blog post at the wrong date). – James Roper Jun 27 '17 at 13:47
9

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.app/Contents/MacOS/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: http://cubewot.de/node/266

image

  • This picture does not have the full path. It is automating the execution of a directory. – ojblass Sep 19 '18 at 4:27
4

For Mac:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --explicitly-allowed-ports=5000,6000,7000

for ports 5000, 6000, and 7000.

3

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 "-"

  • FWIW, the -- on unix is a GNU-specific convention. It's emulated by many, but not all unix utilities. – jpaugh Apr 18 at 14:54
0

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.
Thank you.

protected by Ramhound Feb 28 at 4:43

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.