How to connect NGROK with a Rails application

Category: Ruby :: Published at: 01.07.2021

Ngrok let us to publish our local application for the world. It is very useful for example if we want to create a webhook integration.

These are simple steps to connect NGROK with your rails application:

  • First we need to install ngrok on our computer. If you have mac os and homebrew, you can just use the command bellow
brew install --cask ngrok
  • Then you need to register an account on ngrok website. It is free with some limitations, but for the simple use free account is just enough.
  • Next step is to connect your account with the ngrok library on your computer. To do it you need to paste command bellow
# you can find your token on your ngrok account
ngrok authtoken YOUR_ACCOUNT_TOKEN
  • If your account is connected, you can run your rails server on the standard 3000 port
  • If it works, you can run HTTP tunnel on port of your rails server:
ngrok http 3000
  • The last thing is to add ngrok domain permission to your hosts in development.rb file. It can look like this:
config.hosts << "54g34h654h54hh.ngrok.io"
  • You can restart your rails server and enjoy ngrok features now!

- Click if you liked this article

Views: 599