How to create a route with custom port in Rails 5?

289 views Asked by At

I'm trying to create a dedicated health check route that uses a different port (3001) in Rails 5. my route should just render the text response "Up and running" but use a port different to the default app port while the app runs on the default port as usual.

def healthcheck
  render plain: 'Up and running'
end  

Thanks for the help!

2

There are 2 answers

0
Walter Garcia On

Have you tried to run rails s -p 3001 ?

0
hashrocket On

You can change the port by editing your config/puma.rb file. You’re looking for this line:

port ENV.fetch(“PORT”) { 3000 }

Change the 3000 to the port you want to use.