I am using an HTTP proxy server to connect to the internet.

Because of that my pings are not working

ping www.google.com

says Unreachable Host

How can I configure ping to use the HTTP proxy?

  • It may be helpful to know what setup you are using? Is this a linux server with squid and iptables for example? – Tim Alexander Aug 13 '10 at 9:51

In general you can't. ping needs a direct network connection on the IP level to do its work. A proxy works on a higher layer of the TCP/IP network model, where there is no direct access to the IP protocol.

You would need to somehow circumvent the proxy (change firewall settings, use a VPN, ...). Whether this is possible (and allowed) depends on your network configuration, but it's probably not possible.

As a workaround, there are many web-based ping services available (search for "web-based ping"). These will work.

  • Web-based pings cannot be used to test the latency of my own connection, as they are initiated from the server. Maybe some implementation of ping in java that runs in the browser. – Jose Gómez Sep 8 '15 at 8:14
  • While the ICMP protocol operates on ISO/OSI layer 3, the ping utility operates on layer 7. To quote my CS teacher, ping is a 3-7 hybrid. It may well be possible that the layer 7 part is capable of proxy handling. This would explain why my answer to this question works (at least for me). – s3lph Sep 13 '15 at 18:56
  • @the_Seppi: Interesting, I've never heard of ping being layer 7. Do you have any pointers for further reading? – sleske Sep 13 '15 at 20:28

You may try this,But first you have to install curl.

http_proxy=http://<proxy_username>:<proxy_password>@<your_proxy_server>:<your_proxy_port>  curl -I http://google.com/
  • 18
    this is not PING. – törzsmókus Feb 24 '15 at 20:42
  • 1
    or you can use curl -x 'http://<proxy_username>:<proxy_password>@<your_proxy_server>:<your_proxy_port>' – phyatt Dec 7 '17 at 18:20
  • 1
    @törzsmókus: But it is likely a good answer to the source of the question ... to test, if some server is available and working! – Andreas Dietrich Nov 19 '18 at 9:51
  • The question was, How can I configure ping to use the HTTP proxy? This post by @Ishant Mrinal does not answer that. If someone asks a question [How] to test, if some server is available and working [from behind a proxy?], feel free to add this answer, and also link to it in the comments of this question. – törzsmókus Nov 19 '18 at 12:05
  • 1
    @törzsmókus - You are correct in that the answer does not address strictly the question. It may be the case that the OP (or other readers searching for a similar idea, as myself) asks this while not being specifically interested in using ping, but in using it only as a quick way to test if a given PC is reaching the outside network (as another use, besides the comment by Andreas Dietrich). I found this answer useful (the main idea behind SO), and so did at least other 8 users. – sancho.s Jan 8 at 6:38

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.