GitHub Codespaces Port Forwarding Not Working
Quick answer
Codespaces forwards a port only when the app prints a localhost URL. Forward it manually, open it from the VS Code notification or Ports tab (not localhost in your own browser), and restart the app after the codespace wakes.
Most likely fix: Forward and open the port
How to fix it
Try these in order — the most common fix is first.
1. Forward and open the port
- Add the port manually in the Ports tab
- Open it from the notification in the bottom-right of VS Code or by clicking the URL in the Terminal
Did this fix it?2. After a restart
- Start the application again once the codespace restarts
Did this fix it?3. Visibility and URLs
- If Public or Organization is missing, ask an admin about the port visibility policy
- Use environment variables instead of hardcoded forwarded URLs in tests
Did this fix it?
Symptoms
Forwarded port will not open, is not forwarded automatically, stops after a restart, or the public/organization visibility option is missing.
Why it happens
- App did not print a localhost URL to the console
- Typing localhost on your machine while using the browser editor does not reach the codespace
- Codespace stopped after inactivity, which stopped your app
- An organization policy restricts port visibility
- A hardcoded forwarded URL broke because GitHub can change the forwarding domain
This guide also covers
- codespaces port forwarding not working
- codespace port not opening
- codespaces localhost not working
Still not working?
If GitHub Codespaces keeps failing, you're not alone. See every GitHub Codespaces problem users report or the alternatives people switch to.
Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.
Talk to usThe same problem in other apps
Other GitHub Codespaces errors
- Codespace Running in Recovery Mode: "This codespace is currently running in recovery mode due to a container error"
- GitHub Codespaces Creation Failed
- Can't Create a Codespace: No Option to Create on the Repository
- GitHub Codespaces "503 Service Unavailable" Error
- Codespaces "Oh no, it looks like you are offline" and Other Connection Errors
- Codespace Out of Storage: How to Free Disk Space
- Codespaces Included Usage Used Up: Core Hours and Storage Quota
- Codespaces Prebuild Not Working: "Prebuild Ready" Label Missing