39

I have a project in my local created with springBoot, java, jHipster, Angular, etc and I want to run it. Usually I have used mvnw to run the project. Now I changed computer so when running mvnw in cmd it says app running in https://localhost:8080 and when I go to this link I cannot have access to the app.

This is the message:

This site can’t provide a secure connection
localhost sent an invalid response.
Try running Windows Network Diagnostics.
ERR_SSL_PROTOCOL_ERROR

Maybe I need to install apache so I can access to the projects in localhost? I do not remeember if I had apache installed in my old pc wheer I could access to teh app.

I did netstat -ano | findstr 8080 in cmd and found in task manager that port 8080 is used by java.exe. Maybe it is a port issue? Thanks!

Jonathan Gagne
  • 4,241
  • 5
  • 18
  • 30
coolest
  • 677
  • 1
  • 6
  • 17
  • on the angular.json file, go to architect -> serve -> builder -> configuration and after browserTarget, add the host option like this, "host": "127.0.0.1", and it should work like a charm – ezhupa99 Mar 18 '23 at 02:48

10 Answers10

76

You have to use the HTTP protocol instead, as you don't need to use a SSL Certificate.

Change it from:

https://localhost:8080

To:

http://localhost:8080

Then you should not have the error again.

Jonathan Gagne
  • 4,241
  • 5
  • 18
  • 30
  • 3
    I do not see the reason of your answer but it was teh other way around. – coolest Oct 06 '18 at 10:11
  • 1
    Thanks for your explanation! The reason why I had the problem was that I was using https instead of http that could be the right one. Sorry your answer seems to say the otherway around. – coolest Oct 06 '18 at 10:18
  • 1
    Again I want to accept your answer but for the other people it may be confusing. Just change the places of protocols. That's all. Just because you helped me it is not enough. The question gotta be helpful for others too. – coolest Oct 06 '18 at 10:20
  • 1
    Accepted! Hey people, http protocol helps in this case. So my bad to use https instead of http. – coolest Oct 06 '18 at 10:26
  • 21
    I have tried that, but it automatically changes to "https" when I enter – ph33nyx Oct 02 '19 at 13:53
  • To assume that you don't need https is not a correct assumption. for example if you depend on external authentication that use OIDC and client_id. – Gi1ber7 Oct 15 '19 at 14:11
  • 4
    What a difference a year makes, @ph33nyx... Chrome 68+ now forces https. For Angular apps, you can add another line to your package.json "scripts" section. I use: "start": "ng serve --port 4200", "startSSL": "ng serve --ssl --port 4200", Starting the site as startSSL will allow you to run SSL on localhost (NOTE: might also require withCredentials: true to be added to your HttpInterceptor) – jaygeek Jul 20 '20 at 15:38
  • 2
    It works if you use the IP: 127.0.0.1:8080 – Mr Patience Dec 09 '21 at 12:03
41

If changing to http does not work for you: in your chromium based browser, go to url:

  • for chrome: chrome://net-internals/#hsts
  • for edge: edge://net-internals/#hsts
  • for brave: brave://net-internals/#hsts

Under Delete domain security policies enter localhost or your problem domain and click the delete button on screen

Gerrie Pretorius
  • 3,381
  • 2
  • 31
  • 34
2

I have a same problem with google chrome. After check offered solutions, it's not worked. (Even I used http instead of https, but chrome redirect itself to https).
So I used Mozilla Firefox and Microsoft Edge, it worked! I don't know how to resolve it in google chrome!
Have you any offer about this?

Hamid Talebi
  • 1,298
  • 2
  • 24
  • 42
1

if you are opening in 'localhost' , then you have to provide http, because the local computer cannot provide a secure connection(https). so, try this....

Yougendar
  • 19
  • 1
0

This is normal behavior because you don't use the https protocol.

0

I know this has a solution, but in case you are still endountering the issue after changing https to http in the URL, then your chorme browser might always redirect the localhost to https. This guide should help in that case: https://howchoo.com/chrome/stop-chrome-from-automatically-redirecting-https

0

It also happens when we accidentally use wrong environment key. After checking all chrome related solutions, I found that the env key was invalid. Putting the correct one solves this issue for me.

Salman
  • 588
  • 4
  • 10
0
  1. Open Powershell
  2. cd to your app folder
  3. Run ng serve --ssl --port 4200 and Enter
  4. Go to Chrome and enter https://localhost:4200/
  5. You will get the warning: Your connection isn't private
  6. Click Advanced and click on Continue to localhost (unsafe)
Joel Wiklund
  • 1,697
  • 2
  • 18
  • 24
0

I had the same problem, and it was very simple to solve.

The correct way to open localhost is: http://... but the browser is saving https://... in cache, just clear the browser's cache and it will work.

  • This behavior is going to vary by browser (and possibly version), so please add more specific info to your answer. – benc Feb 21 '23 at 09:12
0

If you are still having an issue in Chrome, try this:

chrome://flags/#allow-insecure-localhost

Getting Chrome to accept self-signed localhost certificate

Tasha
  • 1