Home / AWS / EC2
EC2 Connection refused fix note 6
An operator checklist for narrowing down Connection refused errors in EC2 and preventing recurrence.
First command
grep -R "Connection refused" ./logsFirst evidence
For EC2 Connection refused, first collect timestamp, request URL, affected user, latest change, and the first matching log line.
Search queries
EC2 Connection refusedAWS error Connection refusedEC2 Connection refused fix note 6
When this happens
Use this when the same error repeats in a live website or API, or when it appears only for some users after a deploy.
Symptom checklist
- The browser or API client shows an error code.
- Server logs repeat failed requests around the same time.
- It often follows deploys, DNS changes, certificate renewals, or permission changes.
- It may reproduce only on some networks or specific paths.
Likely causes
- Configuration does not match the real production environment.
- A proxy, load balancer, DNS record, or certificate layer is seeing a different state.
- Permissions, paths, ports, firewall rules, or data state changed.
- Cache or propagation delay makes results differ by user.
- Judging only from the visible error code without logs easily misses the real cause.
First 1-minute checks
- Write down the first failure time and the latest change.
- Separate browser output, server logs, and external command results.
- Check the same URL through the proxy and directly against the origin.
- List reproducing and non-reproducing conditions side by side.
First evidence
For EC2 Connection refused, first collect timestamp, request URL, affected user, latest change, and the first matching log line.
Output examples
Normal output
grep -R "Connection refused" ./logs
# no matching Connection refused entries during the checked windowFailing output
grep -R "Connection refused" ./logs
# Connection refused appears with timestamp, request path, user, and upstream layerOutput-to-action branches
- No matching error appears at the same time.
Start outside the origin: browser, CDN, proxy, DNS cache, or client network. - The same timestamp and path appear in logs.
Inspect the service, upstream, permission, or data state that produced that log line. - Working and failing users get different output.
Compare permissions, session state, network location, and cache state.
Do not do this
- Do not change multiple settings from the visible code alone.
- Do not start with global cache purge, broad permission grants, or disabled security controls before identifying the failing layer.
Evidence quality
Operator draft: includes baseline output examples and branches. Real incident output and official-source links continue through the update queue.
Commands to run first
grep -R "Connection refused" ./logscurl -Iv https://example.comtail -n 200 /var/log/app/error.logsystemctl status nginxFix order
- Record the screen users saw and the actual request URL.
- Check deploy, DNS, certificate, and permission changes around the start time.
- Align application and web server logs by timestamp.
- Compare external command results with control panel state.
- Remove candidate causes one by one and re-check after fixing.
Actions by cause
- Revert the latest change or correct it to the intended value.
- Compare logs from successful and failed requests.
- Separate origin, proxy, DNS, and certificate layers one by one.
- Re-run the same command after the fix and record the result.
Evidence links
- AWS Elastic Load Balancing troubleshooting official
- AWS CloudFront troubleshooting official
Verification metadata
- operator-draft
- official-reference-linked
- 2026-07-23
Update queue
- Review cadence
weekly-source-review - Next enrichment
Add one official-source check and one real output example for AWS Connection refused.
Environment-specific checks
- For shared hosting, first check the control panel completion state.
- If Cloudflare or ALB is in front, always separate origin and proxy results.
- If office networks, VPN, or cache servers exist, also test from an external network.
- On Japanese hosting, SSL and DNS propagation timing may differ from what the control panel shows.
Prevent it next time
- Add verification commands and normal examples to the deploy checklist.
- Record before and after values for DNS, SSL, firewall, and permission changes.
- Keep frequent errors as notes in the same format.
- Split alerts by error rate, response time, disk, and certificate expiry.