diff --git a/libsoup/soup-proxy-resolver-static.c b/libsoup/soup-proxy-resolver-static.c
index 9432767..43ab209 100644
--- a/libsoup/soup-proxy-resolver-static.c
+++ b/libsoup/soup-proxy-resolver-static.c
@@ -9,6 +9,8 @@
 #include <config.h>
 #endif
 
+#include <string.h>
+
 #include "soup-proxy-resolver-static.h"
 #include "soup.h"
 
@@ -87,8 +89,19 @@ soup_proxy_resolver_static_get_property (GObject *object, guint prop_id,
 	}
 }
 
+static gboolean
+should_bypass_proxy (SoupURI *uri)
+{
+	/* Bypass proxy if host is localhost or 127.0.0.0/8 */
+	if (!g_ascii_strcasecmp (uri->host, "localhost") || !strncmp (uri->host, "127.0.0.", 8))
+		return TRUE;
+
+	return FALSE;
+}
+
 typedef struct {
 	SoupProxyURIResolver *proxy_resolver;
+	SoupURI *uri;
 	SoupProxyURIResolverCallback callback;
 	gpointer user_data;
 } SoupStaticAsyncData;
@@ -100,10 +113,15 @@ idle_return_proxy_uri (gpointer data)
 	SoupProxyResolverStaticPrivate *priv =
 		SOUP_PROXY_RESOLVER_STATIC_GET_PRIVATE (ssad->proxy_resolver);
 
+	SoupURI *proxy_uri = NULL;
+	if (!should_bypass_proxy (ssad->uri))
+		proxy_uri = priv->proxy_uri;
+
 	ssad->callback (ssad->proxy_resolver,
-			SOUP_STATUS_OK, priv->proxy_uri,
+			SOUP_STATUS_OK, proxy_uri,
 			ssad->user_data);
 	g_object_unref (ssad->proxy_resolver);
+	soup_uri_free (ssad->uri);
 	g_slice_free (SoupStaticAsyncData, ssad);
 
 	return FALSE;
@@ -121,6 +139,7 @@ soup_proxy_resolver_static_get_proxy_uri_async (SoupProxyURIResolver  *proxy_res
 
 	ssad = g_slice_new0 (SoupStaticAsyncData);
 	ssad->proxy_resolver = g_object_ref (proxy_resolver);
+	ssad->uri = soup_uri_copy (uri);
 	ssad->callback = callback;
 	ssad->user_data = user_data;
 	soup_add_completion (async_context, idle_return_proxy_uri, ssad);
@@ -135,7 +154,9 @@ soup_proxy_resolver_static_get_proxy_uri_sync (SoupProxyURIResolver  *proxy_reso
 	SoupProxyResolverStaticPrivate *priv =
 		SOUP_PROXY_RESOLVER_STATIC_GET_PRIVATE (proxy_resolver);
 
-	*proxy_uri = soup_uri_copy (priv->proxy_uri);
+	if (!should_bypass_proxy (uri))
+		*proxy_uri = soup_uri_copy (priv->proxy_uri);
+
 	return SOUP_STATUS_OK;
 }
 
