-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
How are you running AnythingLLM?
Local development (GitHub Codespaces / Dev Container)
What happened?
When developing in GitHub Codespaces, the backend dev server on port 3001 is not reliably auto-forwarded / discoverable.
This is confusing because the devcontainer configuration already contains portsAttributes for 3001, but in practice the port may not get forwarded, which prevents the frontend from reaching the backend API using the expected Codespaces forwarded domain.
Expected
- Starting the backend in Codespaces causes port 3001 to appear in the Ports view and be forwarded consistently.
- The frontend can reach
...-3001.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/apiwithout manual port forwarding.
Actual
- Port 3001 sometimes does not auto-forward (or doesn’t show up as forwarded), requiring manual intervention.
gh codespace portscan remain empty until the port is manually forwarded, which also breaks any automation that waits ongh codespace ports | grep 3001.
Are there known steps to reproduce?
- Create a new Codespace for this repo.
- Start the backend (e.g. run the VS Code task “Server: run” or
cd server && yarn dev). - Check the Ports tab and/or run
gh codespace ports -c $CODESPACE_NAME.
Observed: port 3001 is not always forwarded automatically.
Notes on likely root cause (IPv6 / localhost behavior)
There are two related behaviors that appear to contribute to how confusing this is:
portsAttributesdoesn’t force forwarding.
portsAttributes controls labels and what to do after a port is forwarded, but does not guarantee that forwarding will happen. In Codespaces, if the port is not auto-forwarded for any reason, it won’t show up as forwarded.
- VS Code Remote port forwarding has known IPv6 edge cases.
The VS Code Remote extensions have a long-standing issue where port forwarding can be unreliable when a service is bound to the IPv6 loopback address (::1) or when localhost resolves to IPv6 first. This is documented in microsoft/vscode-remote-release#7029.
Even when an application “works locally”, the tunnel may end up targeting an IPv6 loopback address which can break connectivity from the forwarded address.
Reference:
Proposed fix
Explicitly declare forwarded ports in the devcontainer configuration: