Faraday::ConnectionFailed | Net::OpenTimeout execution expired

1.5k Views Asked by At

I’m testing a request using the faraday gem. For some reason, this request /login works locally but not when deployed to Heroku or Render. I get always the same error: Faraday::ConnectionFailed execution expired domain:443 with {“status”:500,“error”:“Internal Server Error”}. The same error occurs when I test directly in Postman. But works in localhost but not in the deployed app.

Can someone point me to what is probably happening? Thanks.

      def login
        Faraday.default_adapter = :net_http

        conn = Faraday.new(
          url: 'https://subdomain.example.com',
          params: { version: '4.2.1', client: 'ios' },
          headers: { 'Content-Type': 'application/json' }
        )

        response = conn.post('/authentication') do |req|
          req.body = { username: 'username', password: 'password' }.to_json
        end

        render json: { status: response.status, body: response.body }
      end
1

There are 1 best solutions below

0
ferrisoxide On

Do you have the literal string "https://subdomain.example.com" in your code, because that domain doesn't exist?

The only way I can see this working locally if you have some of local config set up, e.g. a hosts file, that points to a web server at 'subdomain.example.com'. Unless I've misunderstood the question.