# SOCKS5 vs HTTP Proxy

### Intro

GoProxies now added a SOCKS5 (TCP) proxy , which allows you to have another way to connect. Below we will explain in greater detail how to actually set your environment to use this proxy type.

### SOCKS5

SOCKS5 proxies operate on a lower level than HTTP proxies, making them useful in more protocols and applications. That being said, HTTP proxies still have their own strengths.

### Why Use SOCKS5 Over HTTP?

1. **It is protocol-agnostic (not just HTTP/HTTPS)**

SOCKS5 works at the TCP level, meaning it supports any application protocol (HTTP, HTTPS, SMTP, FTP, SSH tunnels, WebSockets, custom TCP apps).

2. **Better for non-browser traffic and scraping**

When dealing with API scraping, automation tools, or TCP-based clients, SOCKS5 has a tendency to be more reliable.

3. **No content editing**

HTTP proxies may modify or inject headers. SOCKS5 simply forwards bytes, making it ideal for applications that are sensitive to header integrity.

4. **Faster in some scenarios**&#x20;

Because SOCKS5 is simpler (no request parsing), it can reduce overhead for certain types of traffic.

### Why Use HTTP Proxies Instead of SOCKS5?

1. **Built-in support in web technologies**

Browsers, HTTP clients, and many SDKs natively support HTTP proxies without extra libraries.

2. **Easier debugging**

HTTP proxies can log or inspect HTTP traffic. SOCKS5 merely passes raw TCP which isn’t visibile.

3. **Ideal for web-only workloads**

If your workload is pure HTTPS/REST API traffic, HTTP proxies are often sufficient and simpler.

Code Examples:

Below are some example snippets for SOCKS5 use written in various coding languages:<br>

<br>

{% tabs %}
{% tab title="cURL" %}

```bash
curl -x socks5://customer-username:password@proxy.goproxies.com:10003 https://ipinfo.io
```

{% endtab %}

{% tab title="Javascript (Node.js)" %}

```javascript
import fetch from "node-fetch";
import { SocksProxyAgent } from "socks-proxy-agent";

const agent = new SocksProxyAgent("socks5://customer-username:password@proxy.goproxies.com:10003");

const res = await fetch("https://ipinfo.io", { agent });
console.log(await res.text());
```

{% endtab %}

{% tab title="Python (Requests + PySocks)" %}

```python
import requests

proxies = {
    'http':  'socks5://customer-username:password@proxy.goproxies.com:10003',
    'https': 'socks5://customer-username:password@proxy.goproxies.com:10003'
}

response = requests.get("https://ipinfo.io", proxies=proxies)
print(response.text)

```

{% endtab %}

{% tab title="Go (with proxy/socks5)" %}

```go
package main

import (
	"fmt"
	"io"
	"net/http"

	"golang.org/x/net/proxy"
)

func main() {
	auth := proxy.Auth{
		User:     "customer-username",
		Password: "password",
	}
	dialer, _ := proxy.SOCKS5("tcp", "proxy.goproxies.com:10003", &auth, proxy.Direct)

	httpTransport := &http.Transport{
		Dial: dialer.Dial,
	}

	client := &http.Client{Transport: httpTransport}

	resp, _ := client.Get("https://ipinfo.io")
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Java (via jsocks or ProxySelector)" %}

```java
import java.net.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Proxy proxy = new Proxy(Proxy.Type.SOCKS,
                new InetSocketAddress("proxy.goproxies.com", 10003));

        Authenticator.setDefault(new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("customer-username", "password".toCharArray());
            }
        });

        URL url = new URL("https://ipinfo.io");
        URLConnection conn = url.openConnection(proxy);

        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        System.out.println(in.readLine());
    }
}
```

{% endtab %}

{% tab title="Ruby (using socksify)" %}

```ruby
require 'socksify/http'

uri = URI("https://ipinfo.io")

Net::HTTP.SOCKSProxy("proxy.goproxies.com", 10003, "customer-username", "password")
        .start(uri.host, uri.port, use_ssl: true) do |http|

  res = http.get(uri)
  puts res.body
end
```

{% endtab %}

{% tab title="PHP (using curl)" %}

```php
<?php

$ch = curl_init("https://ipinfo.io");

curl_setopt_array($ch, [
    CURLOPT_PROXY => "socks5://proxy.goproxies.com:10003",
    CURLOPT_PROXYUSERPWD => "customer-username:password",
    CURLOPT_RETURNTRANSFER => true
]);

echo curl_exec($ch);
curl_close($ch);
```

{% endtab %}
{% endtabs %}

<br>

<br>

<br>
