How to disable "Cannot Render Console from..." on Rails

You need to specifically allow the 10.0.2.2 network space in the Web Console config.

So you'll want something like this:

class Application < Rails::Application
  config.web_console.permissions = '10.0.2.2'
end

Read here for more information.

As pointed out by pguardiario, this wants to go into config/environments/development.rb rather than config/application.rb so it is only applied in your development environment.


Hardcoding an IP into a configuration file isn't good. What about other devs? What if the ip changes?

Docker-related config should not leak into the rails app whenever possible. That's why you should use env vars in the config/environments/development.rb file:

class Application < Rails::Application
  # Check if we use Docker to allow docker ip through web-console
  if ENV['DOCKERIZED'] == 'true'
    config.web_console.whitelisted_ips = ENV['DOCKER_HOST_IP']
  end
end

You should set correct env vars in a .env file, not tracked into version control.

In docker-compose.yml you can inject env vars from this file with env_file:

app:
  build: .
  ports:
   - "3000:3000"
  volumes:
    - .:/app
  links:
    - db
  environment:
    - DOCKERIZED=true
  env_file:
    - ".env"

Based on the feebdack received in comments, we can also build a solution without environment variables:

class Application < Rails::Application
  # Check if we use Docker to allow docker ip through web-console
  if File.file?('/.dockerenv') == true
    host_ip = `/sbin/ip route|awk '/default/ { print $3 }'`.strip
    config.web_console.whitelisted_ips << host_ip
  end
end

I'll leave the solutions with env var for learning purposes.


Auto discovery within your config/development.rb

config.web_console.whitelisted_ips = Socket.ip_address_list.reduce([]) do |res, addrinfo|
    addrinfo.ipv4? ? res << IPAddr.new(addrinfo.ip_address).mask(24) : res
end

Of course might need to add

require 'socket'
require 'ipaddr'

Within your file.


You can whitelist single IP's or whole networks.

Say you want to share your console with 192.168.0.100. You can do this:

class Application < Rails::Application
  config.web_console.whitelisted_ips = '192.168.0.100'
end

If you want to whitelist the whole private network, you can do:

class Application < Rails::Application
  config.web_console.whitelisted_ips = '192.168.0.0/16'
end

If you don't wanna see this message anymore, set this option to false:

class Application < Rails::Application
  config.web_console.whiny_requests = false
end

Be careful what you wish for, 'cause you might just get it all

This is probably only for development purposes so you might prefer to place it under config/environments/development.rb instead of config/application.rb.