Connection refused or timeout: troubleshoot by layer

Check the destination and listener, then the network path, TLS and authentication instead of treating every failure as a port conflict.

For TCP services you are authorized to access. Error messages are clues, not proof of a single cause. Do not scan systems outside your scope.

1. Confirm the target and execution context

Record hostname, port, transport, TLS mode and whether the command runs on the host or in a container. localhost refers to the current environment. A browser is not a database protocol test.

2. Separate listener and network checks

Inspect server listeners and startup logs. Refusal can mean no listener or active rejection; timeouts can involve loss, routing, filtering or load. Check host, firewall, cloud rules and container publishing in order instead of disabling protection.

3. After TCP succeeds, inspect the application

For your local HTTP service, use a bounded request like this. HTTP 401/403, TLS errors and database authentication failures need different remedies, not process killing or broad firewall changes. Keep certificate validation enabled for HTTPS.

curl --noproxy "*" --connect-timeout 3 --max-time 10 -I http://127.0.0.1:8080/

Sources and review

Sources checked on:

Related ports