Code-server: localhost refused to connect when viewing pdf file

Created on 3 Jul 2020  路  6Comments  路  Source: cdr/code-server


I use the code-server with latex-workshop for remote latex editing. But there is a problem that when I try to view the pdf file, it always reported "localhost refused to connect". I made it in docker using Ubuntu 20.04 image and work with jupyterhub, and also tried directly in Ubuntu 20.04, both the same error.

Thanks.

  • Web Browser: Chrome/New Edge
  • Local OS: Windows 10
  • Remote OS: Ubuntu/Ubuntu Docker
  • Remote Architecture: X64
  • code-server --version: 3.4.1
bug extension

All 6 comments

From the discussion from Latex-Workshop, the pdf viewer listen only internal address localhost, I see that there is /proxy// sub path for this, but when I use this, still get error connect ECONNREFUSED. Is that possible to solve this?

/proxy/<port number>/ doesn't show the PDF viewer for you? I tried testing but the extension from our marketplace looks like it wasn't built properly so it errors on activation and I haven't been able to test myself yet.

We have an issue for this localhost problem (https://github.com/cdr/code-server/issues/1510) but it requires changes on the extension's end. I'm not sure whether there's a way for us to fix it on our end or for users to work around it manually. We might be able to automatically replace localhost with the proxy URL but I ran into issues the last time I tried that.

cc @cmoog re the extension not activating.

From my test, the extension works. Only pdf viewer fails. And the standalone pdf viewer extension vscode-pdf works. But they cannot work together, and latex-workshop develop group insist the localhost way for the security consideration.

I have the same exact use case and problem.
More specifically, choosing the tab setting for https://github.com/James-Yu/LaTeX-Workshop/wiki/View#latex-workshopviewpdfviewer results in the error message "Error loading webview: Service Workers are not enabled in browser. Webviews will not work", while choosing the browser setting results in a new browser tab being opened pointinting at localhost (as an aside, to replicate one might need to install latex workshop directly from the vsix file, installing from within code-server did not work for me, see https://github.com/cdr/code-server/issues/1828).

The reference issue at the latex-workshop repo is: https://github.com/James-Yu/LaTeX-Workshop/issues/1265, where it is claimed that

To my opinion, code-server itself should support WebView as VS Code Remote Development does. This is an upstream issue.

Is there a way to resolve this impasse?

That error might mean that you aren't using https since browsers only allow service workers in a secure context.

The only way I can think of to work around the localhost issue without making the required code changes is to forward localhost ports to the remote host. Otherwise the only solution is to wait until we can implement one of the fixes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Arsaev picture Arsaev  路  3Comments

sa7mon picture sa7mon  路  3Comments

tecosaur picture tecosaur  路  3Comments

nol166 picture nol166  路  3Comments

justmao945 picture justmao945  路  3Comments