Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTraining Poplify
12,079 PointsHow to change default port in rails5.
I tried to change by writing port ENV.fetch("PORT") { 4000 } in puma.rb? But in terminal it says: Rails 5.0.0.1 application starting in development on http://localhost:3000.
2 Answers
Ilya Dolgirev
35,375 PointsYou can use
rails server -p 4000
Another option is to export environment variable named PORT and assign it to desired port like this:
export PORT=4000
Then you just use
rails server
But remember that after restart you'll lose that variable and you'll have to export it again.
I do recommend you to use dotenv
gem to manage stuff like this
Ilya Dolgirev
35,375 PointsThe best way to get the answer is to check it literally as you described it ;)
The answers are both YES and NO. YES, you can do it if your projects are different. Just assign the desired ports. NO if you'll try to start the same projects on different ports.
Training Poplify
12,079 PointsTraining Poplify
12,079 PointsThanks Ilya Dolgirev, I have one more doubt. Can we run multiple localhost at a time. Like one project is running on localhost:3000 and another project is on localhost:4000