I am using a proxy to connect to internet. I can use firefox and software center. but can not ping google. when I try it says

ping google.com

ping: unknown host google.com

I have tried with ip address also. it says Destination Host Unreachable.

please help. Thanks in advance.

  • That doesn't matter in this case... – s3lph Mar 2 '14 at 15:44
  • yes, You are right. I found that I am also suffering from same problem. – g_p Mar 2 '14 at 15:46
  • If you're accessing through proxy.. then have you tried applying proxy system wide under network... :) – AzkerM Mar 2 '14 at 15:50
  • Little strange problem. I can ping when I am connected using ppp interface but can't when using my samsung wave mobile wifi hotspot. – g_p Mar 2 '14 at 15:55
  • I guess the phone accesses the internet via 3G etc. so you don't need the proxy there – s3lph Mar 3 '14 at 17:04

For bash commands you have to set the proxy seperately. For this, you have to set a environment variable, e.g.:

ping google.com    # can't resolve, no proxy set
export http_proxy=proxy.example.com:1234
ping google.com    # works, proxy set for this bash session.

Replace the address and the port with your proxy configuration. If you're always behind this proxy, add the export http_proxy... command to ~/.bashrc so it gets executed every time you start a new bash session.

Or to execute a single command with proxy settings and without setting environment variables, use env, e.g.:

env http_proxy=proxy.example.com:1234 ping google.com
sudo env http_proxy=proxy.example.com:1234 apt-get install cowsay

To use other services, e.g. HTTPS or FTP you have to set different variables:

export https_proxy=proxy.example.com:1234
export ftp_proxy=proxy.example.com:1234
| improve this answer | |
  • 1
    This seems to contradict superuser.com/a/175441/269366. Has ping gained new functionality? – Carsten S Sep 13 '15 at 16:20
  • Actually, the SU answer is only partially correct: While the ICMP protocol itself is on the IP layer, the ping utility itself operates on the application layer. My CS teacher once had some problems in explaining this properly, and simply declared ping as a hybrid of ISO/OSI layer 3 and 7. – s3lph Sep 13 '15 at 18:50
  • Thanks for the reply. I still do not see how an http proxy should help, but I do not currently have access to a system where I could test this. – Carsten S Sep 13 '15 at 19:09
  • 1
    This doesn't work! I am behind institute proxy and have set the environment variables correctly. But can't ping google.com "unknow host" – rootkea Feb 27 '17 at 16:48
  • 1
    ping uses the utilities provided as part of the application layer; true. But it creates a RAW socket for ICMP protocol essentially ignoring all other higher levels. So this doesn't work and never worked. In fact, it ignores the proxy env variable entirely as if it is no set. Also, HTTP, HTTPS, SOCKS and FTP proxy are all TCP and UDP proxy and therefore not capable of forwarding other requests. Not to mention the fact that you also need to configure your system to forward DNS queries (which is possible via SOCKS) beforehand to be able to ping google.com. – Soroush Falahati Dec 29 '19 at 20:13

ping doesn't work through proxy.

But you can use utility httping for that. It sends a HEAD request (by default) to a web server and measures the time it took to get a response.


httping -x -g http://google.com

Example output:

➜  ~ httping -x localhost:1080 -g http://google.com -c 3
PING google.com:80 (/):
connected to (313 bytes), seq=0 time= 38.49 ms 
connected to (313 bytes), seq=1 time= 66.94 ms 
connected to (313 bytes), seq=2 time= 40.79 ms 
--- http://google.com/ ping statistics ---
3 connects, 3 ok, 0.00% failed, time 3162ms
round-trip min/avg/max = 38.5/48.7/66.9 ms


  • -x - Address of a proxy server, port is optional
  • -g - URL to send a request to

Other useful options:

  • -5 - Use SOCKS5. Should be put after the -x option, i.e.:

    httping -x localhost:1080 -5 -g http://google.com
  • -c - How many probes to send before exiting. Infinite by default.

  • -G - Do a GET request instead of a HEAD request. That means that also full page/file will be transferred. Note that in this case you're no longer measuring the latency! Useful for testing actual websites.

Be noticed that the time measured also includes the latency introduced by the proxy server itself.

The utility is available through a number of repositories for different OS'es and Linux distros:


sudo apt install httping


sudo apk add httping

macOS with Homebrew:

brew install httping

Here is a link to the author's website:


| improve this answer | |

Try this:

Open a terminal. Ctrl + Alt + T

Run it:

$ sudo -i
# nano /etc/bash.bashrc

Put the following lines in the file:

export http_proxy=http://my_proxy_server:3128/
export https_proxy=http://my_proxy_server:3128/
export ftp_proxy=http://my_proxy_server:3128/
export socks_proxy=socks://my_proxy_server:3128/

Ctrl + U, paste. Ctrl + O, save file. Ctrl + X, close nano.

$ sudo -i
# nano /etc/environment

Put the following lines in the file


Ctrl + U, paste. Ctrl + O, save file. Ctrl + X, close nano.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.