333mmm333
333mmm3332mo ago

Help using apify proxy without sdk

I'm trying to use apify proxys without sdk, using my own framework. But i keep getting Proxy Authentication Required errors.
func NewApifyProxyClientFromEnv() (*ApifyProxyClient, error) {
hostname := os.Getenv("APIFY_PROXY_HOSTNAME")
port := os.Getenv("APIFY_PROXY_PORT")
password := os.Getenv("APIFY_PROXY_PASSWORD")

// Dump all environment variables for debugging
proxyClientLog.Debug("Dumping all environment variables:")
for _, env := range os.Environ() {
if strings.Contains(env, "APIFY_PROXY_PASSWORD") {
proxyClientLog.Debugf(" %s=********", strings.SplitN(env, "=", 2)[0])
} else {
proxyClientLog.Debugf(" %s", env)
}
}

if hostname == "" || port == "" || password == "" {
return nil, fmt.Errorf("APIFY_PROXY_HOSTNAME, APIFY_PROXY_PORT, or APIFY_PROXY_PASSWORD environment variables not set")
}

groups := []string{"BUYPROXIES94952"}
if groupsStr := os.Getenv("APIFY_PROXY_GROUPS"); groupsStr != "" {
groups = strings.Split(groupsStr, ",")
}

return NewApifyProxyClient(hostname, port, password, groups, "", ""), nil // Pass empty strings for session and country
}
func NewApifyProxyClientFromEnv() (*ApifyProxyClient, error) {
hostname := os.Getenv("APIFY_PROXY_HOSTNAME")
port := os.Getenv("APIFY_PROXY_PORT")
password := os.Getenv("APIFY_PROXY_PASSWORD")

// Dump all environment variables for debugging
proxyClientLog.Debug("Dumping all environment variables:")
for _, env := range os.Environ() {
if strings.Contains(env, "APIFY_PROXY_PASSWORD") {
proxyClientLog.Debugf(" %s=********", strings.SplitN(env, "=", 2)[0])
} else {
proxyClientLog.Debugf(" %s", env)
}
}

if hostname == "" || port == "" || password == "" {
return nil, fmt.Errorf("APIFY_PROXY_HOSTNAME, APIFY_PROXY_PORT, or APIFY_PROXY_PASSWORD environment variables not set")
}

groups := []string{"BUYPROXIES94952"}
if groupsStr := os.Getenv("APIFY_PROXY_GROUPS"); groupsStr != "" {
groups = strings.Split(groupsStr, ",")
}

return NewApifyProxyClient(hostname, port, password, groups, "", ""), nil // Pass empty strings for session and country
}
INFO[2025-07-17T16:34:52Z] Assigned session-specific proxy groups-BUYPROXIES98951,session-global_pool_session_0:*@10.0.47.64:8011 to session global-pool-session-0
I'm not sure what is wrong, this is beeing run inside the apify containers, i've checked that the envs are correct and tested using a simpler session name. i always get : WARNING[2025-07-17T16:43:59Z] Worker: Request via proxy 10.0.90.88:8011 failed with status 403 (attempt 1/3). Retrying... component=httpclient
Solution:
never mind, i've just realized i was getting a 407 proxy error and i've fixed it and now it is 403, the apify datacenter proxy does not work with the site
Jump to solution
1 Reply
Solution
333mmm333
333mmm3332mo ago
never mind, i've just realized i was getting a 407 proxy error and i've fixed it and now it is 403, the apify datacenter proxy does not work with the site

Did you find this page helpful?