-
-
Save ejholmes/7bf14e04f51f00c8e77f179eda0ece44 to your computer and use it in GitHub Desktop.
Connection errors with basic auth credentials in URL string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
) | |
func main() { | |
_, err := http.Get("http://user:pass@localhost:12345") | |
log.Fatal(err) | |
} | |
// 2018/03/27 20:07:28 Get http://user:pass@localhost:12345: dial tcp [::1]:12345: getsockopt: connection refused | |
// exit status 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
contents = urllib2.urlopen("http://user:pass@localhost:12345").read() | |
# Traceback (most recent call last): | |
# File "test.py", line 2, in <module> | |
# contents = urllib2.urlopen("http://user:pass@localhost:12345").read() | |
# File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen | |
# return opener.open(url, data, timeout) | |
# File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 431, in open | |
# response = self._open(req, data) | |
# File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 449, in _open | |
# '_open', req) | |
# File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain | |
# result = func(*args) | |
# File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1227, in http_open | |
# return self.do_open(httplib.HTTPConnection, req) | |
# File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1197, in do_open | |
# raise URLError(err) | |
# urllib2.URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "net/http" | |
require "uri" | |
uri = URI.parse("http://user:pass@localhost:12345/") | |
# Full | |
http = Net::HTTP.new(uri.host, uri.port) | |
response = http.request(Net::HTTP::Get.new(uri.request_uri)) | |
puts response | |
# /Users/ejholmes/.rbenv/versions/2.3.3/lib/ruby/2.3.0/net/http.rb:882:in `rescue in block in connect': Failed to open TCP connection to localhost:12345 (Connection refused - connect(2) for "localhost" port 12345) (Errno::ECONNREFUSED) | |
# from /Users/ejholmes/.rbenv/versions/2.3.3/lib/ruby/2.3.0/net/http.rb:879:in `block in connect' | |
# from /Users/ejholmes/.rbenv/versions/2.3.3/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout' | |
# from /Users/ejholmes/.rbenv/versions/2.3.3/lib/ruby/2.3.0/timeout.rb:101:in `timeout' | |
# from /Users/ejholmes/.rbenv/versions/2.3.3/lib/ruby/2.3.0/net/http.rb:878:in `connect' | |
# from /Users/ejholmes/.rbenv/versions/2.3.3/lib/ruby/2.3.0/net/http.rb:863:in `do_start' | |
# from /Users/ejholmes/.rbenv/versions/2.3.3/lib/ruby/2.3.0/net/http.rb:852:in `start' | |
# from /Users/ejholmes/.rbenv/versions/2.3.3/lib/ruby/2.3.0/net/http.rb:1398:in `request' | |
# from test.rb:8:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment