How do I make curl ignore the proxy?

Curl

Curl Problem Overview


How do I make curl ignore the proxy? Setting $NO_PROXY doesn't seem to work for me.

Curl Solutions


Solution 1 - Curl

If your curl is at least version 7.19.4, you could just use the --noproxy flag.

curl --noproxy '*' http://www.stackoverflow.com

From the manual.

Solution 2 - Curl

I ran into the same problem because I set the http_proxy and https_proxy environment variables. But occasionally, I connect to a different network and need to bypass the proxy temporarily. The easiest way to do this (without changing the environment variables) is:

curl --noproxy '*' stackoverflow.com

From the manual: "The only wildcard is a single * character, which matches all hosts, and effectively disables the proxy."

The * character is quoted so that it is not erroneously expanded by the shell.

Solution 3 - Curl

I assume curl is reading the proxy address from the environment variable http_proxy and that the variable should keep its value. Then in a shell like bash, export http_proxy=''; before a command (or in a shell script) would temporarily change its value.

(See curl's manual for all the variables it looks at, under the ENVIRONMENT heading.)

Solution 4 - Curl

This works just fine, set the proxy string to ""

curl -x "" http://www.stackoverflow.com

Solution 5 - Curl

Add your proxy preferences into .curlrc or _curlrc (windows)

proxy = 1.2.3.4
noproxy = .dev,localhost,127.0.0.1

This make all dev domains and local machine request ignore the proxy.

See man page proxy and noproxy on same page.

Solution 6 - Curl

Long shot but try setting the proxy to "" (empty string) that should override any proxy settings according to the man page.

Solution 7 - Curl

You should use $no_proxy env variable (lower-case). Please consult https://wiki.archlinux.org/index.php/proxy_settings for examples.

Also, there was a bug at curl long time ago http://sourceforge.net/p/curl/bugs/185/ , maybe you are using an ancient curl version that includes this bug.

Solution 8 - Curl

First, I listed the current proxy setting with

env | sort | less

(should be something like http_proxy=http://wpad.local.machine.location:port number)

Then I tried setting

export http_proxy=";" 

which gave this error message:

curl: (5) Couldn't resolve proxy ';'

Tried

export http_proxy="" && curl http://servername:portnumber/destinationpath/ -d 55

and it worked!

PS! Remember to set http-proxy back to its original settings with

export http_proxy=http://wpad.local.machine.location:port number

Solution 9 - Curl

I have http_proxy and https_proxy are defined. I don't want to unset and set again those environments but --noproxy '*' works perfectly for me.

curl --noproxy '*' -XGET 172.17.0.2:9200
{
  "status" : 200,
  "name" : "Medusa",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "1.5.0",
    "build_hash" : "544816042d40151d3ce4ba4f95399d7860dc2e92",
    "build_timestamp" : "2015-03-23T14:30:58Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.4"
  },
  "tagline" : "You Know, for Search"
}

Solution 10 - Curl

In case of windows: use curl --proxy "" ...

Solution 11 - Curl

Lame answer but: Remember to make sure no proxy is set in a ~/.curlrc file (...).

Solution 12 - Curl

In my case (macos, curl 7.54.0), I have below proxy set with ~/.bash_profile

$ env |grep -i proxy |cut -d = -f1|sort
FTP_PROXY
HTTPS_PROXY
HTTP_PROXY
NO_PROXY
PROXY
ftp_proxy
http_proxy
https_proxy
no_proxy

With unknown reason, this version of curl can't work with environment variables NO_PRXY and no_proxy properly, then I unset the proxy environment variables one by one, until to both HTTPS_PROXY and https_proxy.

unset HTTPS_PROXY
unset https_proxy

it starts working and can connect to internal urls

So I would recommend to unset all proxy variables if you have in your environment as temporary solution.

unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY

Solution 13 - Curl

My curl was not ignoring the proxy on Ubuntu 12.04 until I set the "no_proxy" (lowercase) environment variable. The --noproxy option was not available.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionksuraltaView Question on Stackoverflow
Solution 1 - CurlScott OffenView Answer on Stackoverflow
Solution 2 - CurlwisbuckyView Answer on Stackoverflow
Solution 3 - CurlAnonymousView Answer on Stackoverflow
Solution 4 - CurlericcurtinView Answer on Stackoverflow
Solution 5 - CurlClemens TolboomView Answer on Stackoverflow
Solution 6 - CurlLouisView Answer on Stackoverflow
Solution 7 - CurlDmitriusanView Answer on Stackoverflow
Solution 8 - CurlbenettispaghettiView Answer on Stackoverflow
Solution 9 - CurlprayagupaView Answer on Stackoverflow
Solution 10 - CurlVISHAL DAGAView Answer on Stackoverflow
Solution 11 - Curljtlz2View Answer on Stackoverflow
Solution 12 - CurlBMWView Answer on Stackoverflow
Solution 13 - Curluser2646026View Answer on Stackoverflow