oc Port Forward Examples¶
Introduction¶
oc port-forward creates a temporary local tunnel to a pod or service. It is useful for testing an internal app without creating a Route.
When You Need This Command¶
Use this command when you need to inspect, change, or verify OpenShift resources from the terminal without relying on the web console.
Syntax¶
oc <command> <resource> [name] -n <project>
Practical Examples¶
oc port-forward service/web 8080:8080 -n app
curl -sS http://127.0.0.1:8080/health
oc get endpoints web -n app
Example output:
Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080
OK
Verification¶
oc get events -n app --sort-by=.lastTimestamp
oc get pods -n app -o wide
Common Mistakes¶
- Looking only at the final error and ignoring events.
- Checking the wrong project with oc.
- Changing several objects at once before confirming the current state.
Production Notes¶
Run read-only commands first, check the active project, and prefer declarative manifests for repeatable changes.
Quick Checklist¶
- Confirm the active project.
- Inspect the exact object named in the error.
- Read recent events.
- Apply one focused fix.
- Verify status after the change.
Related Guides¶
Summary¶
oc Port Forward Examples is most useful when paired with verification. Check the project, run the command against the intended object, and confirm the resulting OpenShift state.