ERR_CONNECTION_CLOSED when trying to open local site

When trying to run a local site on devkinsta I am getting this error:

This site can’t be reached

mpdebuggin-1.local unexpectedly closed the connection.

Try:

ERR_CONNECTION_CLOSED

the site worked a few days ago… not sure what changed.
in the log file on my pc I see these errors:
[2022-03-23 12:24:50.923] [info] [ProgressIndicator] { isFailed: false, isOpen: false }
[2022-03-23 12:24:50.925] [info] [ProgressIndicator] { isFailed: false, isOpen: false }
[2022-03-23 12:24:56.300] [error] Error: =[31;1mError:[0m Error establishing a database connection.
at file:///C:/Users/Racheli/AppData/Local/Programs/DevKinsta/resources/app.asar/dist/renderer.prod.js:2:890867
at tryCatch (file:///C:/Users/Racheli/AppData/Local/Programs/DevKinsta/resources/app.asar/dist/renderer.prod.js:8:2491963)
at Generator._invoke (file:///C:/Users/Racheli/AppData/Local/Programs/DevKinsta/resources/app.asar/dist/renderer.prod.js:8:2491586)
at Generator.next (file:///C:/Users/Racheli/AppData/Local/Programs/DevKinsta/resources/app.asar/dist/renderer.prod.js:8:2492729)
at asyncGeneratorStep (file:///C:/Users/Racheli/AppData/Local/Programs/DevKinsta/resources/app.asar/dist/renderer.prod.js:2:1003)
at _next (file:///C:/Users/Racheli/AppData/Local/Programs/DevKinsta/resources/app.asar/dist/renderer.prod.js:2:1302)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2022-03-23 12:24:56.413] [error] Error: =[31;1mError:[0m Error establishing a database connection.
at file:///C:/Users/Racheli/AppData/Local/Programs/DevKinsta/resources/app.asar/dist/renderer.prod.js:2:890867
at tryCatch (file:///C:/Users/Racheli/AppData/Local/Programs/DevKinsta/resources/app.asar/dist/renderer.prod.js:8:2491963)
at Generator._invoke (file:///C:/Users/Racheli/AppData/Local/Programs/DevKinsta/resources/app.asar/dist/renderer.prod.js:8:2491586)
at Generator.next (file:///C:/Users/Racheli/AppData/Local/Programs/DevKinsta/resources/app.asar/dist/renderer.prod.js:8:2492729)
at asyncGeneratorStep (file:///C:/Users/Racheli/AppData/Local/Programs/DevKinsta/resources/app.asar/dist/renderer.prod.js:2:1003)
at _next (file:///C:/Users/Racheli/AppData/Local/Programs/DevKinsta/resources/app.asar/dist/renderer.prod.js:2:1302)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

How do I solve this?
Thanks!

Hi @Rachel365, welcome to DevKinsta!

Can you open Docker Desktop and maker sure and make sure all of your Containers and Apps are running?

Hi! I also have this problem. All dockers are running. I also had this last week, than I deleted all DevKinsta and Docker files and I had access again, but it is not a sustainable solution. Can I get help?

Hey Angelo, can you please provide a screenshot of the error?

Hi Allesandro, it works again, very strange…
But now I’ve another error.

When I try to open a local site, it redirects to another local site. When I close all local sites except for the one I try to open, I got this error “Site stopped by DevKinsta”.
I checked the site url in the database, but this is correct. I also tried to close DevKinsta and Docker, but it didn’t work.

This is the log:

[2023-08-30 09:25:07.327] [info]  [SiteNav]: Navbar reloaded, unread message: no
[2023-08-30 09:25:07.327] [info]  [dockerUtil/getContainer] Get 'devkinsta_fpm' Docker container
[2023-08-30 09:25:07.327] [info]  [isWpSite] Checking if studionul is a Wordpress site
[2023-08-30 09:25:07.329] [info]  [getDbSize] update studionul site's db size
[2023-08-30 09:25:07.329] [info]  [dockerUtil/getContainer] Get 'devkinsta_fpm' Docker container
[2023-08-30 09:25:07.329] [info]  [ViewSite] checking wp site version
[2023-08-30 09:25:07.329] [info]  [ViewSite] checking site unread emails
[2023-08-30 09:25:07.331] [info]  [dockerUtil/getContainer] Get 'devkinsta_fpm' Docker container
[2023-08-30 09:25:07.333] [info]  [getSiteMailbox] Update site mailbox with API query: search?kind=containing&query=studionul.local
[2023-08-30 09:25:07.340] [info]  Response: 200 OK
[2023-08-30 09:25:07.340] [info]  Response headers: {
  'content-type': 'application/json',
  date: 'Wed, 30 Aug 2023 07:25:07 GMT',
  'content-length': '42',
  connection: 'close'
}
[2023-08-30 09:25:07.340] [info]  Response data: { total: 0, count: 0, start: 0, items: [] }
[2023-08-30 09:25:07.340] [info]  [getSiteMailbox] 0 emails retrieved. for domain studionul.local
[2023-08-30 09:25:07.366] [info]  [useMailhog] Mail socket opened.
[2023-08-30 09:25:07.489] [info]  [containerExec] Command 'cd /www/kinsta/public/studionul && wp --allow-root --skip-themes --skip-plugins core version' on devkinsta_fpm finished with exit code 0
[2023-08-30 09:25:07.490] [info]  [checkWpVersion] site's current version 6.3
[2023-08-30 09:25:07.490] [info]  [checkWpVersion] site's stored version 6.3
[2023-08-30 09:25:07.490] [info]  [checkWpVersion] containerExec response test true
[2023-08-30 09:25:08.077] [info]  [containerExec] Command 'cd public/studionul && wp --allow-root --skip-themes --skip-plugins db size --size_format=b --url=https://studionul.local:62091' on devkinsta_fpm finished with exit code 0
[2023-08-30 09:25:08.112] [info]  [containerExec] Command 'wp --allow-root --skip-themes --skip-plugins core is-installed --path=/www/kinsta/public/studionul' on devkinsta_fpm finished with exit code 0
[2023-08-30 09:25:08.112] [info]  [useWordpressCheck] Studio Nul is a wp site, setting it to WP.

type or paste code here

Heya Angelo :wave:

I’ve never encountered this issue (local site redirects to another local site) on my local computer/DevKinsta :thinking:
What if you try to create a new/fresh WordPress site in DevKinsta (just for testing purpose), does it load properly ? or does it also redirect to that same (another) local site ?

Perhaps you may want to check the access log file of that local site that redirects to another local site. It can be found under the ~/DevKinsta/logs sub-folder (e.g.: sitename_access.log file).
You can open the terminal on your local computer and try to execute this command line:
tail -f sitename_access.log

then try to access that local site URL on your browser - and if it redirects to another local site, it should be logged in that site access log file - that usually will show 301 or 302 , and if you can share that to us here.

Also on your terminal on your local computer, you may want to try to execute this command line:
curl -Ik https://yourlocalsitename.local
(and provide the results to us here as well - so we will have more information/details to check further)

When I close all local sites except for the one I try to open, I got this error “Site stopped by DevKinsta”.

I’m not sure about this, but what do you mean with close all local sites (and how did you do it exactly, was it just to close the browser’s tabs that opened those local sites)?

That “Site stopped by DevKinsta” usually means that the site has been stopped in DevKinsta. Perhaps you may want to check in your DevKinsta → Sites → the site name in question → Site status section (see if that site in question is stop? if that so try to click the “Start site” button and re-check on your browser).

Regards,
Agus

hi Agus,

Very strange right? When I create a new environment it works.
The access log of the website I can’t reach because it redirects is empty. Maybe because it redirects to the other local site. What can I try?

When I remove the environment and pull it works again, but some environments are 10gb or 5gb and will take a lot of time to pull.

Hi @whadaday :wave:

Can we have the curl output as @Agus mentioned? (On an environment that you can’t reach)

Except, make that:

curl -vv -IkL https://yourlocalsitename.local

This way we can inspect each step of the redirect and any errors or debug statements included

curl -vv -IkL https://studionul.local

  • Trying [::1]:443…
  • connect to ::1 port 443 failed: Connection refused
  • Trying 127.0.0.1:443…
  • connect to 127.0.0.1 port 443 failed: Connection refused
  • Failed to connect to studionul.local port 443 after 4 ms: Couldn’t connect to server
  • Closing connection 0
    curl: (7) Failed to connect to studionul.local port 443 after 4 ms: Couldn’t connect to server

Thank you for your reply Agelo!

Based on that curl report you provide, looks like your local site(s) in DevKinsta was not set with the default/standard ports (HTTP = 80 , HTTPS = 443 ) .

Could you please check on your DevKinsta → Settings (the icon on the bottom left side) → scroll down and local the “Port selector” and un-check the “[ ] Auto-detect open ports”-> set the HTTP field with 80 and set the HTTPS field with 443 and click the “Confirm” button.

After that on your DevKinsta, click on the Sites → the sitename of studionul.local → and locate the SSL and HTTPS, and make sure that the “HTTPS” toggle has been enabled (to ensure this site will be accessible through https:// protocol).

Then, please try to access that local site URL https://studionul.local on your browser (in incognito mode just to be sure) - and see if it’s loading properly (and not redirecting to any other local site)?

Please also test with CURL again: curl -vv -IkL https://studionul.local
and give us the results from it (in case it’s still redirecting , so we can check / review ).

Regards,
Agus

Hi Agus,

When I try to change the ports it says that the ports 80/443 are already being used.
The auto selected ports are 62090/62091.

I am also using LocalWP for my non Kinsta projects. Could there be conflicts?

I see, yeah if you have any other web server/service runs on your local computer (and they use the same standard or default ports 80/443) then those ports can’t be used again (would be conflicted) by NGINX in DevKinsta or vice-versa (if those have been used by NGINX in DevKinsta, the same ports can’t be used by the other web servers).

In this case, since the ports used/assigned were: 62090 (HTTP) and 62091 (HTTPS) - as shown in your DevKinsta’s settings (Port Selector), then if you would like to access your DevKinsta’s local sites , you would need to add the port as well in the URL (on your browser) such as for example:

http://studionul.local:62090
https://studionul.local:62091 (when HTTPS/SSL has been enabled for this site)

see if the URLs above work fine on your browser (and if those are not redirecting to any other local site?)

And for the CURL command line, that would be like this for example to test/check the results:
curl -vv -IkL https://studionul.local:62091

I’ve never used LocalWP before, so not quite sure if it would conflict with DevKinsta’s local sites (and if that’s the case here with the site being redirected to another local site).
For testing purpose, you may want to try to close LocalWP software completely (and make sure its web service is completely shutdown as well), and try to set the default ports mentioned before in your DevKinsta’s settings ( Port Selector ) and see if the local site(s) can be accessed just fine as well without additional custom port mentioned above.

Regards,
Agus

Hi Agus,

curl -vv -IkL https://houseofdeeprelax.local:62091
*   Trying [::1]:62091...
* Connected to houseofdeeprelax.local (::1) port 62091 (#0)
* ALPN: offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=danielnogueira.local; C=US; ST=CA; L=West Hollywood; O=Kinsta; OU=DevKinsta
*  start date: Aug 31 17:03:39 2023 GMT
*  expire date: Aug 28 17:03:39 2033 GMT
*  issuer: CN=danielnogueira.local; C=US; ST=CA; L=West Hollywood; O=Kinsta; OU=DevKinsta
*  SSL certificate verify ok.
* using HTTP/2
* h2 [:method: HEAD]
* h2 [:scheme: https]
* h2 [:authority: houseofdeeprelax.local:62091]
* h2 [:path: /]
* h2 [user-agent: curl/8.1.2]
* h2 [accept: */*]
* Using Stream ID: 1 (easy handle 0x7fda52012800)
> HEAD / HTTP/2
> Host: houseofdeeprelax.local:62091
> User-Agent: curl/8.1.2
> Accept: */*
> 
< HTTP/2 200 
HTTP/2 200 
< server: nginx
server: nginx
< date: Fri, 01 Sep 2023 04:43:04 GMT
date: Fri, 01 Sep 2023 04:43:04 GMT
< content-type: text/html; charset=UTF-8
content-type: text/html; charset=UTF-8
< link: <https://danielnogueira.local:62091/wp-json/>; rel="https://api.w.org/"
link: <https://danielnogueira.local:62091/wp-json/>; rel="https://api.w.org/"

< 
* Connection #0 to host houseofdeeprelax.local left intact

Thanks Angelo for that curl results!

That’s strange indeed, as you requested to call https://houseofdeeprelax.local:62091
but the server certificate somehow shows/returns different local site name/url ( danielnogueira.local ) instead:

  • Server certificate:
  • subject: CN=danielnogueira.local; C=US; ST=CA; L=West Hollywood; O=Kinsta; OU=DevKinsta
  • start date: Aug 31 17:03:39 2023 GMT
  • expire date: Aug 28 17:03:39 2033 GMT
  • issuer: CN=danielnogueira.local; C=US; ST=CA; L=West Hollywood; O=Kinsta; OU=DevKinsta
  • SSL certificate verify ok.

and it actually didn’t redirect (301/302) to the danielnogueira.local site either, but just returned with the HTTP 200 response ( HTTP/2 200 ) - though the link there also shows that another local site name:

link: < https://danielnogueira.local:62091/wp-json/>; rel=“https://api.w.org/

I suspect there might be something with the NGINX configs of that local sites that might have changed somehow :thinking:

Could you please open terminal, and cd / go inside the : ~/DevKinsta/nginx_sites subfolder ?
then please perform this command: cat houseofdeeprelax.conf (and copy paste the results here)
as well as to perform: cat danielnogueira.conf (and copy paste the results here)
so we can check and review that to make sure they are correctly setup.
(you may also want to compare with NGINX config file of the new site you created before - which worked fine/not redirect/load another local site)

Regards,
Agus

Hi Agus,

hereby:

server {
  set $site_name houseofdeeprelaxcom;
  set $php_path devkinsta_fpm:9004;

  listen 52034;
  listen [::]:52034;
  listen 52035 ssl http2;
  listen [::]:52035 ssl http2;

  ssl_certificate /www/kinsta/ssl/houseofdeeprelaxcom.local.crt;
  ssl_certificate_key /www/kinsta/ssl/houseofdeeprelaxcom.local.key;

  server_name  houseofdeeprelaxcom.local *.houseofdeeprelaxcom.local;
  access_log   /www/kinsta/logs/houseofdeeprelaxcom_access.log main;
  error_log    /www/kinsta/logs/houseofdeeprelaxcom_error.log;

  root /www/kinsta/public/houseofdeeprelaxcom;
  index index.php index.html;

  include multisite_subdir.conf;

  location / {
      try_files $uri $uri/ /index.php?$args;
  }

  location ~ \.php$ {
      fastcgi_split_path_info ^(.+?\.php)(/.*)$;
      if (!-f $document_root$fastcgi_script_name) {
        return 404;
      }
      include fastcgi_params;
      fastcgi_param PHP_ADMIN_VALUE "sendmail_from=devkinsta@houseofdeeprelaxcom.local";
      fastcgi_intercept_errors on;
      fastcgi_pass $php_path;
      fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

server {
  set $site_name danielnogueira;
  set $php_path devkinsta_fpm:9003;

  listen 62090;
  listen [::]:62090;
  listen 62091 ssl http2;
  listen [::]:62091 ssl http2;

  ssl_certificate /www/kinsta/ssl/danielnogueira.local.crt;
  ssl_certificate_key /www/kinsta/ssl/danielnogueira.local.key;

  server_name  danielnogueira.local *.danielnogueira.local;
  access_log   /www/kinsta/logs/danielnogueira_access.log main;
  error_log    /www/kinsta/logs/danielnogueira_error.log;

  root /www/kinsta/public/danielnogueira;
  index index.php index.html;

  include multisite_subdir.conf;

  location / {
      try_files $uri $uri/ /index.php?$args;
  }

  location ~ \.php$ {
      fastcgi_split_path_info ^(.+?\.php)(/.*)$;
      if (!-f $document_root$fastcgi_script_name) {
        return 404;
      }
      include fastcgi_params;
      fastcgi_param PHP_ADMIN_VALUE "sendmail_from=devkinsta@danielnogueira.local";
      fastcgi_intercept_errors on;
      fastcgi_pass $php_path;
      fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

Hi Changed the ports to

set $php_path devkinsta_fpm:9003;

  listen 62090;
  listen [::]:62090;
  listen 62091 ssl http2;
  listen [::]:62091 ssl http2;

Now I get this error. This is with and without ssl activated

400 Bad Request
The plain HTTP request was sent to HTTPS port
nginx

Heya Angelo :slight_smile:

Thank you for the update! Yeah the settings look a bit different for both sites.
You may want to check the other local site’s NGINX config file as well - that’s loading/working properly (to compare and to make sure it’s also set with the same ports as set for that danielnogueira site).
I checked mine and could see all of my local sites’ NGINX config files were set up with the same ports.

May I know how exactly did you change that houseofdeeprelaxcom NGINX .conf file ?
Did you try to change it via DevKinsta → Sites → site name in question → click the “Wrench” icon on the left side → NGINX Editor (Save changes) section ?

Also after you changed that NGINX config file from that editor in DevKinsta, please also try to restart the NGINX docker’s container via terminal with this command;
docker restart devkinsta_nginx
then see if the site can be accessed on your browser?

Regards,
Agus

Hi Agus,

Yes it works. After I changed it, it was browser cache which led me to the 400 error page.
Thank you for your help!

Cheers, Angelo

1 Like

Glad to hear it worked for you now Angelo! :clap: :+1:
You’re always welcome! :bowing_man:

Regards,
Agus