ScrapeGraphAI/Scrapegraph-ai · error · ValueError
Invalid proxy server format: {proxy['server']}
Error message
Invalid proxy server format: {proxy['server']} What it means
ValueError from parse_or_search_proxy: the proxy['server'] URL could not be parsed to a hostname (urlparse(...).hostname is None). The server string must be a URL with a host, e.g. 'http://host:port'.
Source
Thrown at scrapegraphai/utils/proxy_rotation.py:201
"""If a proxy address conforms to a IPv4 address"""
try:
ipaddress.IPv4Address(address)
return True
except ipaddress.AddressValueError:
return False
def parse_or_search_proxy(proxy: Proxy) -> ProxySettings:
"""
Parses a proxy configuration or searches for a matching one via broker.
"""
assert "server" in proxy, "Missing 'server' field in the proxy configuration."
parsed_url = urlparse(proxy["server"])
server_address = parsed_url.hostname
if server_address is None:
raise ValueError(f"Invalid proxy server format: {proxy['server']}")
# Accept both IP addresses and domain names like 'gate.nodemaven.com'
if is_ipv4_address(server_address) or re.match(
r"^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", server_address
):
return _parse_proxy(proxy)
assert proxy["server"] == "broker", f"Unknown proxy server type: {proxy['server']}"
return _search_proxy(proxy)
View on GitHub (pinned to 532dfffbf6)
Solutions
- Set server to a full URL: 'http://user:pass@host:port' or 'socks5://host:port'
- Validate the string with urlparse before building the graph
- Use a domain or IPv4 host (both are accepted once parseable)
Example fix
# before
config = {"proxy": {"server": "gate.nodemaven.com"}}
# after
config = {"proxy": {"server": "http://user:pass@gate.nodemaven.com:8080"}} Defensive patterns
Strategy: validation
Validate before calling
from urllib.parse import urlparse
h = urlparse(proxy["server"]).hostname
if not h:
raise ValueError("proxy server must include scheme://host:port") Type guard
from urllib.parse import urlparse
def is_valid_proxy_server(server: str) -> bool:
return isinstance(server, str) and urlparse(server).hostname is not None Try / catch
try:
parsed = parse_or_search_proxy(proxy)
except ValueError as e:
raise ValueError(f"check proxy config: {e}") from e Prevention
- Always include scheme and host: 'http://host:port'
- Validate proxy URLs in config loaders
- Prefer provider URLs with credentials over bare hostnames
When it happens
Trigger: Passing proxy={'server': '8080'} or {'server': ':8080'} or a scheme-only string — anything without a parseable host part.
Common situations: Configuring proxy dicts with just a port, missing scheme/host, or malformed credentials embedded in the URL breaking parsing.
Related errors
- The 'graphviz' library is required for this functionality. P
- The browserbase module is not installed. Please install it u
- Cannot deep copy object of type {type(obj)}
- Unsupported service tier {service_tier!r} for {model_name}
- missing proxy servers for criteria
AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28).
Data as JSON: /api/errors/8bd085d41c738bf6.
Report an issue: GitHub.