Code-server: How to expose angular port 4200?

Created on 17 Sep 2019  路  7Comments  路  Source: cdr/code-server

First of all, thank you for this awesome project!
Now i setup the code-server to extend my dev setup and have the ability to code on my ipad. I managed to get all of it working (event with angular cli). But now I want to open the page. Angular opens a port 4200 with hot reload etc. How can I expose this port to open the page on my localhost (work machine).

I've run the code-server v2 (latest v2) within a docker container.

question

All 7 comments

For now you'll have to expose the port yourself on the Docker container. Something like -p 127.0.0.1:4200:4200.

Tracking for having a way built into code-server to proxy ports is here: #512

I've already did that but the connection is still refused. Even with curl in the container itself it's still refusing the connection.

Curious. I gave it a shot but curl localhost:4200 inside the
container worked for me. As for accessing it outside of the
container, keep in mind 127.0.0.1 is only available locally (so
only within the container) which means you'll have to do something
like ng serve --host 0.0.0.0.

Can we reopen this to investigate it?

Oh wow, today I just tested it again and now it works but nothing changed. Even the external access on the exposed port 4200 works.

Skip to UPDATE2

I'm having the same issue when trying to start code-server for angular development. I have published the ports in my docker-compose.yml file as following:

version: '3.3'

services:
   code-server:
     image: code-server-ng
     volumes:
       - ./project:/home/coder/project
     ports:
       - "48080:8080"
       - "14200:4200"

However, unlike earlier comment. I can access angular app from inside code-server by getting correct output for curl localhost:4200.

Versions info:

Version: 1.41.1
Commit: f51e045cd5483561afc07694f39307fb673b6d1d
Date: 2020-01-17T22:58:55.612Z
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36 Edg/80.0.361.66
Code Server Version: 2.1698-vsc1.41.1

UPDATE:
The published ports are purposely set to 48080, 14200 accordingly. I'm able to acccess code-server on 48080 without issues. However, can't access angular server on 14200.

UPDATE2:
It was a problem at my end. I didn't feel the need to add --disableHostCheck to ng serve since I'm binding the port to localhost already. But, then after trying it I realised it's working.

Happy to hear you got everything working! Let us know if you have any issues :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rcarmo picture rcarmo  路  3Comments

lshamis picture lshamis  路  3Comments

oonqt picture oonqt  路  3Comments

grant picture grant  路  3Comments

justmao945 picture justmao945  路  3Comments