alexreisner/geocoder · error · ConfigurationError
Error parsing # proxy URL: '#
Error message
Error parsing #{protocol.upcase} proxy URL: '#{proxy_url}' What it means
Raised by Geocoder::Lookups::Base#http_client when the configured :http_proxy (or :https_proxy) string cannot be parsed as a URI. Geocoder wraps URI::InvalidURIError into a Geocoder::ConfigurationError naming the protocol and the offending URL.
Solutions
- Fix the proxy URL so it is a valid URI, e.g. 'http://user:pass@host:port'
- URL-encode special characters in proxy credentials (URI.encode_www_form_component)
- Verify environment variables (HTTP_PROXY etc.) feeding the config are well-formed
- Test with URI.parse(proxy_url) in a console before configuring
Example fix
// before Geocoder.configure(http_proxy: 'proxy mycorp com:3128') // after Geocoder.configure(http_proxy: 'http://proxy.mycorp.com:3128')
Defensive patterns
Strategy: validation
Validate before calling
URI.parse(proxy_url) # call before configuring; rescue URI::InvalidURIError
Type guard
def valid_proxy?(url); !!(URI.parse(url =~ %r{^https?://} ? url : "http://#{url}")); rescue URI::InvalidURIError; false; end Try / catch
begin
Geocoder.search(q)
rescue Geocoder::ConfigurationError => e
raise if e.message !~ /proxy/i
Geocoder.configure(http_proxy: ENV.fetch('HTTP_PROXY'))
end Prevention
- Store fully-formed proxy URLs (scheme://host:port)
- URL-encode usernames/passwords in proxy URLs
- Validate env-derived proxy values at boot
When it happens
Trigger: Setting Geocoder.configure(http_proxy: 'not a url') or an https_proxy value with illegal characters (spaces, missing scheme handled by prefixing but still malformed, stray braces), so URI.parse raises URI::InvalidURIError.
Common situations: Copy-pasting proxy URLs with quotes, whitespace or credentials containing unencoded special characters; reading the proxy from env vars that are empty or malformed.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- Geocoder tried to log a message with an invalid log level.
- Please specify a valid lookup for Geocoder
- Please specify valid logger for Geocoder. Logger specified…
- region_code '# ' is invalid. use one of #…
- The # API requires a key to be configured: #
AI-assisted analysis of alexreisner/geocoder@c10bd70121 (2026-09-15).
Data as JSON: /api/errors/603c7fbc4ef9923a.
Report an issue: GitHub.
Appendix: source
Thrown at lib/geocoder/lookups/base.rb:129
##
# An object with configuration data for this particular lookup.
#
def configuration
Geocoder.config_for_lookup(handle)
end
##
# Object used to make HTTP requests.
#
def http_client
proxy_name = "#{protocol}_proxy"
if proxy = configuration.send(proxy_name)
proxy_url = !!(proxy =~ /^#{protocol}/) ? proxy : protocol + '://' + proxy
begin
uri = URI.parse(proxy_url)
rescue URI::InvalidURIError
raise ConfigurationError,
"Error parsing #{protocol.upcase} proxy URL: '#{proxy_url}'"
end
Net::HTTP::Proxy(uri.host, uri.port, uri.user, uri.password)
else
Net::HTTP
end
end
##
# Geocoder::Result object or nil on timeout or other error.
#
def results(query)
fail
end
def query_url_params(query)
query.options[:params] || {}
endView on GitHub (pinned to c10bd70121)