The middleware list requires it to be designed / stacked in a specific order, otherwise you will encounter this error. The first middleware is considered the most external, which wraps everything else, so the adapter must be the most internal (or the last):
Faraday.new(url: "http://localhost") do |config|
config.request :json
config.response :json
config.adapter Faraday.default_adapter
end
. .