Stop curl from ignoring your proxy when you are testing internal APIs

Networking & Firewall (Ss/Netstat/Iptables/Nftables/Curl)

Stop curl from ignoring your proxy when you are testing internal APIs

🧩 The Challenge

You are trying to debug why a container can’t hit an internal API, but every time you run a test, curl ignores your environment’s proxy settings and tries to go straight to the internet. I’ve spent an embarrassing amount of time changing firewall rules only to realize my test traffic wasn’t even going through the path I thought it was.

💡 The Fix

Just force curl to explicitly use the proxy variable you’ve already defined, so you know exactly which gateway your traffic is actually crossing.

curl -x $http_proxy -I http://internal-service.local/health

⚙️ Why It Works

By passing the -x flag, you are overriding the default behavior where curl might ignore your environment variables or try to resolve the hostname globally. It ensures your test matches the real traffic flow of your application.

🚀 Pro-Tip: Use the -v flag if you still see failures so you can watch the handshake happen in real time.

Linux Tips & Tricks | © ngelinux.com | 8/3/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted