[Feature proposal] Add --port to "rails new" to run local Puma not on port 3000

Hello there!

Every time I create a new Rails app on my laptop my first change after rails new it to set the localhost port to something other than 3000. That’s because only one app can run on the same port at the same time.

My feature proposal is to add a --port option to the rails new command so I can specify the port in the same command, e.g.:

rails new my_app --port 4567

This could also be beneficial for first time users, as they could just set in the same command rather than having to edit config/puma.rb and in config/environments/development.rb to make the change.

Let me know your thoughts. Thanks!

2 Likes

Providing you use something like mise or dotenv you can also set PORT=... in your .env file.

2 Likes

IMO it’s just easier to change that than remember a CLI arg. That said, I could see it being useful to add on a .railsrc file so it’s automatic.

There already is an option to set the port on rails s command