What to do when Blocked Host: "host name" appears in Ruby on Rails

background

In the exercises in Chapter 1 of the Ruby on Rails tutorial, I got the error "Blocked Host: my host name" all the time, and after trying various things for a long time, I did not do a certain fundamental thing. I noticed it and solved it, so I posted this post.

What I tried

What is often written on the Web is

  1. In environment / development.rb, enter "config.hosts.clear". However, when I tried this, the error still occurred.
  2. Enter "config.hosts <<" your host name "" in environment / development.rb. However, when I tried this, the error still occurred.

Cause

(I). Programs 1 and 2 were added to development.rb in a different application. For example, if the application you are creating is hello_app, you have added programs 1 and 2 to development.rb in a different application (eg a_app). This only allows the host for a_app, not the host for hello_app. The reason why I made a mistake is that there are two hierarchical structures, environment / hello_app / config / environment / development.rb, so if you are in the same environment, you can rewrite one development.rb to make it all. It was due to the misunderstanding that it would be reflected. The hierarchy of development.rb is as above, and there is one file for each application. By no means common. Let's rewrite development.rb in config / environment in the application you are creating as 1 and 2.

(II) After rewriting .development.rb, "rails server" was not executed. As for the order, if you do not follow the procedure "Rewrite the program in development.rb-> Execute rails server", no matter how much you follow step (I), the error will still occur.

Recommended Posts

What to do when Blocked Host: "host name" appears in Ruby on Rails
What to do when "call'Hoge.connection' to establish a connection" appears on rails c
[Ruby / Rails] What to do when NoMethodError appears when using a destructive method such as filter!
[Rails Tutorial Chapter 2] What to do when you make a mistake in the column name
What to do when Rails on Docker does not reflect controller changes in the browser
[Rails] What to do when the error No database selected and Unknown database appears in db: migrate
[Ruby on Rails] How to install Bootstrap in Rails
What to do when IllegalStateException occurs in PlayFramework
Notes on what to do when a WebView ClassNotFoundException occurs in JavaFX 12
What to do when rails db: seed does not reflect in the database
What to do when "Nil location provided. Can't build URI." Appears on CarrierWave
What to do if ffi installation fails when launching an application in Rails
[Ruby on Rails] How to write enum in Japanese
[Ruby on Rails] How to change the column name
[Ruby on Rails] Change URL id to column name
[Ruby On Rails] How to reset DB in Heroku
What to do when rails creates a 〇〇 2.rb file
What to do when Address already in use is displayed after executing rails s
What to do when Method not found in f: ajax
What to do when you launch an application with rails
How to display a graph in Ruby on Rails (LazyHighChart)
[Ruby on Rails] Column restrictions when saving to DB (4 representatives)
Apply CSS to a specific View in Ruby on Rails
What to do when ‘Could not find’ in any of the sources appears in the development environment with Docker × Rails × RSpec
Ruby on Rails Japanese-English support i18n
[Ruby on Rails] What is Bcrypt?
What to do when a could not find driver appears when connecting to a DB in a Docker environment
What to do when javax.batch.operations.JobStartException occurs
What to do when an error (StandardError: An error has occurred, this and all later migrations canceled:) appears in rails db: migrate
What to do when an UnsupportedCharsetException occurs in a lightweight JRE
[Rails] What to do if data is not registered in DB
What to do when the changes in the Servlet are not reflected
What to do if the Rails page doesn't appear in Rails tutorial 1.3.2
What to do if Cloud9 is full in the Rails tutorial
[Rails] What to do when rails s does not respond or does not stop
Things to remember and concepts in the Ruby on Rails tutorial
[Programming beginner] What to do when rails s becomes an error in the local development environment
[Ruby] What to do when the error "cannot load such file" appears when executing VS Code debug
How to change app name in rails
[Ruby on Rails] How to use CarrierWave
What to do when a javax.el.PropertyNotWritableException occurs
Ruby on Rails in Visual Studio Codespaces
Deploy to Heroku [Ruby on Rails] Beginner
Preparing to introduce jQuery to Ruby on Rails
[Ruby on Rails] How to use redirect_to
Do not return when memoizing in Ruby
[Ruby on Rails] How to use kaminari
Beginners create portfolio in Ruby on Rails
What to do when undefined method ʻuser_signed_in?'
[Ruby on Rails] Button to return to top
Change from SQLite3 to PostgreSQL in a new Ruby on Rails project
What to do when CentOS cannot be started with VirtualBox on Catalina
How to create a query using variables in GraphQL [Using Ruby on Rails]
What to do and how to install when an error occurs in DXRuby 1.4.7
How to implement gem "summer note" in wysiwyg editor in Ruby on Rails
What to do if deployment fails on Heroku (Ruby app not detected)
Notes on what to do when EC2 is set up with t2.micro
What to do if tomcat process remains when tomcat is stopped in eclipse
How to debug the processing in the Ruby on Rails model only on the console
[Ruby on Rails] How to log in with only your name and password using the gem devise
[Ruby on Rails] When logging in for the first time ・ How to split the screen in half using jQuery