

In the codespace/VSCode terminal: ssh -R 27017:localhost:27017 your_public_ip Simplest set up - direct connectionĪt the time of writing the default Node + Mongo codespace uses Debian buster, so ssh port forwarding would be the obvious choice. To use any other protocol (MongoDb wire protocol in your case) you need to set up a TCP tunnel from codespaces to your machine. The proxy relies on HTTP Host header to route the request to correct upstream so it will work for HTTP protocols only. You can put anything in the v subdomain and it will still be resolved on the DNS level.

Publishing a port alone won't help as all incoming requests are going through an http proxy. I also posted here in the MongoDB community, but no help.
#CONNECT MONGODB COMPASS TO LOCALHOST INSTALL#
# Uncomment if you want to install more global node modules Īnd finally a Docker file: # Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-busterįROM /vscode/devcontainers/javascript-node:0-$" Use 'postCreateCommand' to run commands after the container is created. Use 'forwardPorts' to make a list of ports inside the container available locally. Add the IDs of extensions you want installed when the container is created. Set *default* container specific settings.json values on container create.

"dockerComposeFile": "docker-compose.yml",
#CONNECT MONGODB COMPASS TO LOCALHOST UPDATE#
Update the VARIANT arg in docker-compose.yml to pick a Node.js version # Add "forwardPorts": to **devcontainer.json** to forward MongoDB locally.Īnd a devcontainer.json file // For format details, see. # (Adding the "ports" property to this file will not forward from a Codespace.) # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. # Uncomment the next line to use a non-root user for all processes. # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. # Overrides default command so things don't shut down after the process ends. # Use -bullseye variants on local arm64/Apple Silicon. # Append -bullseye or -buster to pin to an OS version. # Update 'VARIANT' to pick an LTS version of Node.js: 16, 14, 12. I'm actually unsure about how I even determine if MongoDB is actually running in the Github codespace? files It failed with No addresses found at host. I attempted to use the following connection string, but it did not work in MongoDB compass. The address forwarded to 27017 is something like My attempt The port is forwarded, and my objective is to connect with MongoDB Compass running on my local machine. I'm trying out Github codespaces, specifically the "Node.js & Mongo DB" default settings.
