question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERR_CONNECTION / CORS Request did not succeed

See original GitHub issue

“webpack”: “^4.41.5”

vue --version @vue/cli 4.1.2

Bug report

I already asked questions in vue.js forum, in stackoverflow, and in other github reports.

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce.

https://github.com/marcoippolito/testproject

Description of the problem:

I created a brand new tiny webapp with vue cli, so without adding anything, apart from what the empty vue-cli scaffolding brings:

(base) marco@pc:~/vueMatters/testproject$ npm run serve

> testproject@0.1.0 serve /home/marco/vueMatters/testproject
> vue-cli-service serve

INFO Starting development server...
98% after emitting CopyPlugin

DONE Compiled successfully in 1409ms 8:14:46 PM 

And get this error message : https://drive.google.com/open?id=10GcVFmqNVGRjox3wklJtcrAkIWM3kOp8

"GET https://localhost/sockjs-node/info?t=1580228998416 net::ERR_CONNECTION_REFUSED" 

Using firefox as web browser, I get this error message: https://drive.google.com/open?id=1l6USIHrbHl6kBcQtormXplOgx0J653ko

"Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at 
https://localhost/sockjs-node/info?t=1580304400023. (Reason: CORS request did not succeed)."

Looking at Mozilla Developer explanation: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSDidNotSucceed?utm_source=devtools&utm_medium=firefox-cors-errors&utm_campaign=default

"What went wrong?

The HTTP request which makes use of CORS failed because the HTTP connection failed at 
either the network or protocol level. The error is not directly related to CORS, but is a fundamental
network error of some kind.

In many cases, it is caused by a browser plugin (e.g. an ad blocker or privacy protector) blocking 
the request.

Other possible causes include:

Trying to access an https resource that has an invalid certificate will cause this error.
Trying to access an http resource from a page with an https origin will also cause this error.
As of Firefox 68, https pages are not permitted to access http://localhost, although this may be    
changed by Bug 1488740.
The server did not respond to the actual request (even if it responded to the Preflight request).
One scenario might be an HTTP service being developed that panicked without returning any
data.

"

In order to understand where the problem could lie, I checked various aspects:

  • Checked the TLS Certificates with https://www.digicert.com/help/ : and the result is: " TLS Certificate has not been revoked. TLS Certificate expires soon. The primary TLS Certificate expires on February 28, 2020 (30 days remaining) Certificate Name matches ggc.world TLS Certificate is correctly installed "

  • curled the url both from within the PC-Server, and from a laptop:

    -From within the PC-Server:

    (base) marco@pc:~$ curl -Iki https://localhost/sockjs-node/info?t=1580397983088 HTTP/2 405 server: nginx/1.14.0 (Ubuntu) date: Fri, 31 Jan 2020 08:19:02 GMT allow: OPTIONS, GET

    (base) marco@pc:~/vueMatters/testproject$ curl -vk https://localhost/sockjs- node/info?t=1580397983088

      Trying ::1…
      TCP_NODELAY set
      connect to ::1 port 443 failed: Connection refused
      Trying 127.0.0.1…
      TCP_NODELAY set
      Connected to localhost (127.0.0.1) port 443 (#0)
      ALPN, offering h2
      ALPN, offering http/1.1
      successfully set certificate verify locations:
      CAfile: /etc/ssl/certs/ca-certificates.crt
      CApath: /etc/ssl/certs
      TLSv1.3 (OUT), TLS handshake, Client hello (1):
      TLSv1.3 (IN), TLS handshake, Server hello (2):
      TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
      TLSv1.3 (IN), TLS handshake, Unknown (8):
      TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
      TLSv1.3 (IN), TLS handshake, Certificate (11):
      TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
      TLSv1.3 (IN), TLS handshake, CERT verify (15):
      TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
      TLSv1.3 (IN), TLS handshake, Finished (20):
      TLSv1.3 (OUT), TLS change cipher, Client hello (1):
      TLSv1.3 (OUT), TLS Unknown, Certificate Status (22):
      TLSv1.3 (OUT), TLS handshake, Finished (20):
      SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
      ALPN, server accepted to use h2
      Server certificate:
      subject: CN=ggc.world
      start date: Nov 30 11:22:10 2019 GMT
      expire date: Feb 28 11:22:10 2020 GMT
      issuer: C=US; O=Let’s Encrypt; CN=Let’s Encrypt Authority X3
      SSL certificate verify ok.
      Using HTTP2, server supports multi-use
      Connection state changed (HTTP/2 confirmed)
      Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
      TLSv1.3 (OUT), TLS Unknown, Unknown (23):
      TLSv1.3 (OUT), TLS Unknown, Unknown (23):
      TLSv1.3 (OUT), TLS Unknown, Unknown (23):
      Using Stream ID: 1 (easy handle 0x559bc64c5580)
      TLSv1.3 (OUT), TLS Unknown, Unknown (23):
    
      GET /sockjs-node/info?t=1580397983088 HTTP/2
      Host: localhost
      User-Agent: curl/7.58.0
      Accept: /
    
      TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
      TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
      TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
      TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
      TLSv1.3 (IN), TLS Unknown, Unknown (23):
      Connection state changed (MAX_CONCURRENT_STREAMS updated)!
      TLSv1.3 (OUT), TLS Unknown, Unknown (23):
      TLSv1.3 (IN), TLS Unknown, Unknown (23):
      < HTTP/2 200
      < server: nginx/1.14.0 (Ubuntu)
      < date: Fri, 31 Jan 2020 14:00:47 GMT
      < content-type: application/json; charset=UTF-8
      < access-control-allow-origin: *
      < vary: Origin
      < cache-control: no-store, no-cache, no-transform, must-revalidate, max-age=0
      < strict-transport-security: max-age=31536000
      <
      Connection #0 to host localhost left intact
    

    -From a laptop:

    (base) marco@marco-U36SG:~$ curl -Iki https://ggc.world/sockjs-node/info?t=1580397983088 HTTP/1.1 405 Method Not Allowed Server: nginx/1.14.0 (Ubuntu) Date: Fri, 31 Jan 2020 09:34:59 GMT Connection: keep-alive Allow: OPTIONS, GET

    (base) marco@marco-U36SG:~$ curl -vk https://ggc.world/sockjs-node/info?t=1580397983088

      Trying 2.36.58.214:443…
      TCP_NODELAY set
      Connected to ggc.world (2.36.58.214) port 443 (#0)
      ALPN, offering http/1.1
      successfully set certificate verify locations:
      CAfile: /home/marco/anaconda3/ssl/cacert.pem
      CApath: none
     TLSv1.3 (OUT), TLS handshake, Client hello (1):
      TLSv1.3 (IN), TLS handshake, Server hello (2):
      TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
      TLSv1.3 (IN), TLS handshake, Certificate (11):
      TLSv1.3 (IN), TLS handshake, CERT verify (15):
      TLSv1.3 (IN), TLS handshake, Finished (20):
      TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
      TLSv1.3 (OUT), TLS handshake, Finished (20):
      SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
      ALPN, server accepted to use http/1.1
      Server certificate:
      subject: CN=ggc.world
      start date: Nov 30 11:22:10 2019 GMT
      expire date: Feb 28 11:22:10 2020 GMT
      issuer: C=US; O=Let’s Encrypt; CN=Let’s Encrypt Authority X3
      SSL certificate verify ok.
    
      GET /sockjs-node/info?t=1580397983088 HTTP/1.1
      Host: ggc.world
      User-Agent: curl/7.65.2
      Accept: /
    
      TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
      TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
      old SSL session ID is stale, removing
      Mark bundle as not supporting multiuse
      < HTTP/1.1 200 OK
      < Server: nginx/1.14.0 (Ubuntu)
      < Date: Fri, 31 Jan 2020 14:04:11 GMT
      < Content-Type: application/json; charset=UTF-8
      < Transfer-Encoding: chunked
      < Connection: keep-alive
      < Access-Control-Allow-Origin: *
      < Vary: Origin
      < Cache-Control: no-store, no-cache, no-transform, must-revalidate, max-age=0
      < Strict-Transport-Security: max-age=31536000
      <
      Connection #0 to host ggc.world left intact
      {“websocket”:true,“origins”:[":"],“cookie_needed”:false,“entropy”:1587194190}
    
  • This is the output of the “Network” tab : https://drive.google.com/open?id=1QJMe8FEBrEuWacHWeJ_TQegMkF0v68AY

  • This is the “view source” of the html page:

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <link rel="icon" href="favicon.ico"> <title>testproject</title> <link href="js/app.js" rel="preload" as="script"><link href="js/chunk-vendors.js" rel="preload" as="script"></head> <body> <noscript> We're sorry but testproject doesn't work properly without JavaScript enabled. Please enable it to continue. </noscript> <div id="app"></div> <script type="text/javascript" src="js/chunk-vendors.js"></script><script type="text/javascript" src="js/app.js"> </script></body> </html>
  • This is the result of the “localhost” word search in app.js:

    https://drive.google.com/open?id=11QpJKjd4PLKNMnO7m2utCJ9PrzO8Oyji :

      /***/ }),
    
      /***/ 1:
    

/!********************************************************************************************************************************************************************!
!*** multi (webpack)-dev-server/client?http://localhost (webpack)/hot/dev-server.js (webpack)- dev-server/client?http://192.168.1.7:8080/sockjs-node ./src/main.js ! **************************************************************************************************************************************************************/ /! no static exports found / // (function(module, exports, webpack_require) {

    __webpack_require__(/*! /home/marco/vueMatters/testproject/node_modules/webpack-dev-
server/client   
    /index.js?http://localhost */"./node_modules/webpack-dev-server/client/index.js?http:
//localhost");
    __webpack_require__(/*! /home/marco/vueMatters/testproject/node_modules/webpack
/hot/dev-server.js  
    */"./node_modules/webpack/hot/dev-server.js");
    __webpack_require__(/*! /home/marco/vueMatters/testproject/node_modules/webpack-dev-
server/client 
    /index.js?http://192.168.1.7:8080/sockjs-node */"./node_modules/webpack-dev-server/client
/index.js?http:  
    //192.168.1.7:8080/sockjs-node");
    module.exports = __webpack_require__(/*! ./src/main.js */"./src/main.js");
    /***/ })
    /******/ });

In this GitHub repository you can find all the related files: https://github.com/marcoippolito/testproject

The sudo nano /etc/nginx/conf.d/default.conf is the following:

server {
    listen 443 ssl http2 default_server;
    server_name ggc.world;

    ssl_certificate /etc/ssl/certs/chained.pem;
    ssl_certificate_key /etc/ssl/private/domain.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-

draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:! MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:50m; ssl_dhparam /etc/ssl/certs/dhparam.pem; #ssl_stapling on; #ssl_stapling_verify on;

    access_log /var/log/nginx/ggcworld-access.log combined;

    add_header Strict-Transport-Security "max-age=31536000";
    location = /favicon.ico { access_log off; log_not_found off; }
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    error_page 497 https://$host:$server_port$request_uri;
    server_name www.ggc.world;
    return 301 https://$server_name$request_uri;

    access_log /var/log/nginx/ggcworld-access.log combined;

    add_header Strict-Transport-Security "max-age=31536000";
    location = /favicon.ico { access_log off; log_not_found off; }
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

# https://www.nginx.com/blog/nginx-nodejs-websockets-socketio/
# https://gist.github.com/uorat/10b15a32f3ffa3f240662b9b0fefe706 
# http://nginx.org/en/docs/stream/ngx_stream_core_module.html

upstream websocket {
    ip_hash;
    server localhost:3000;
}

server {
    listen       81;
    server_name  ggc.world www.ggc.world;

    #location / {
    location ~ ^/(websocket|websocket\/socket-io) {
        proxy_pass http://127.0.0.1:4201;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Forwared-For $remote_addr;
        proxy_set_header Host $host;

        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
    }

}
# https://stackoverflow.com/questions/40516288/webpack-dev-server-with-nginx-proxy-pass

What is the expected behavior? : no ERR_CONNECTION

Other relevant information: webpack version: “webpack”: “^4.41.5” Node.js version: node -v v12.10.0 Operating System: Ubuntu 18.04.03 Server Edition Additional tools:

  • npm -v 6.13.6
  • webpack-cli@3.3.10
  • nginx -v nginx version: nginx/1.14.0 (Ubuntu)
  • vue --version @vue/cli 4.1.2 Looking forward to your kind help. Marco

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
marcoippolitocommented, Feb 3, 2020

@appsparkler I’m using Ubuntu Server Edition in my development machine because I need to use an environment as close as possible to the production environment.

To me it’s not clear why a Server Edition should interfere with sockjs-node and webpack not, if, opening in the browser the files before the ERR_CONNECTION failures, I read, when searcing for sockjs-node and use of localhost, references to webpack:

sockejsError17

Anyway, I’m going to post an issue in Ubuntu Server Edition’s platform, referring to this github’s issue and your hypothesis about a bug/problem related to the Ubuntu 18.04.03 Server Edition.

And I will keep you informed about the results in other forums

0reactions
appsparklercommented, Feb 7, 2020

Hi @marcoippolito,

According to you, what kind of problems/missing parts/lacking features or whatever the Ubuntu 18.04.4 Server Edition could have compared to the Ubuntu 18.04.4 Desktop Edition?

Not sure about this. Lets hope someone responds with a solution in the askubuntu forum. Please update this discussion if you get any info.

Good Luck…

Read more comments on GitHub >

github_iconTop Results From Across the Web

laravel - CORS request did not succeed - Stack Overflow
For me this error was caused by a self-signed certificate. If you open developer tools, select the network tab, click the call that...
Read more >
error: CORS request did not succeed · Issue #306 - GitHub
I think this is an issue due to server configuration and issues in OpenVSX repository should about the OpenVSX in general, affecting both...
Read more >
ERR_CONNECTION / CORS Request did not succeed - Help
The HTTP request which makes use of CORS failed because the HTTP connection failed at either the network or protocol level. The error...
Read more >
CORS did not succeed - WordPress.org
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at {key here}. (Reason: CORS request did not succeed).
Read more >
Troubleshoot CORS errors from API Gateway - AWS
I get the error "No 'Access-Control-Allow-Origin' header is ... to check the request and response parameters from the failed API request.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found