LinuxCommandLibrary

rails-server

Start the Rails development web server

TLDR

Start the Rails development server

$ rails server
copy
Start the server on a specific port
$ rails server -p [port]
copy
Start the server binding to all interfaces
$ rails server -b 0.0.0.0
copy
Start the server in production environment
$ rails server -e production
copy
Start using a specific server (Puma, Thin, etc.)
$ rails server -u [puma|thin|webrick]
copy
Start in daemon mode (background)
$ rails server -d
copy

SYNOPSIS

rails server [-p port] [-b address] [-e environment] [-d] [-u server]

DESCRIPTION

rails server starts a web server for the Rails application. By default, it uses Puma and listens on http://localhost:3000 in the development environment.
The server automatically reloads code changes in development mode, allowing rapid iteration without restarts. It displays request logs in the terminal, showing HTTP methods, paths, response codes, and timing information.
Binding to 0.0.0.0 makes the server accessible from other machines on the network, useful for testing on mobile devices or from other computers.

PARAMETERS

-p, --port PORT

Run server on specified port (default: 3000)
-b, --binding IP
Bind to specified IP address (default: localhost)
-e, --environment ENV
Run in specified environment (development, test, production)
-d, --daemon
Run server as a daemon (background process)
-u, --using SERVER
Use specified Rack server (puma, thin, webrick, etc.)
-P, --pid FILE
Specify PID file path
-C, --dev-caching
Toggle development mode caching
--early-hints
Enable HTTP/2 early hints
-h, --help
Show help information

CAVEATS

The default binding to localhost (127.0.0.1) only accepts connections from the local machine. Use -b 0.0.0.0 to accept external connections, but be aware of security implications.
Development mode is not suitable for production. It lacks performance optimizations and may expose debugging information. Always use -e production with a proper production configuration for deployed applications.
The daemon mode (-d) requires manual process management. Use process managers like systemd or Passenger for production deployments.

SEE ALSO

rails(1), puma(1), rails-routes(1), bundle(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community