Specify the Port When Starting the Hugo Server - Command Option (hugo server --port)

You can specify the port when starting the Hugo server. This is useful when running multiple Hugo servers.

When you start a Hugo server with the hugo server command, it starts a web server that uses port 1313 by default.

However, if you try to start multiple Hugo servers at the same time, later Hugo servers are assigned arbitrary port numbers. Port numbers from the private port range, 49152 to 65535, are used.

Specify the Port

To specify an arbitrary port number, use the -p (--port) option as follows.

Example: Start the Hugo server with port number 51234

$ hugo server -p 51234

Start Multiple Hugo Servers at the Same Time

When starting multiple Hugo servers at the same time, it is best to decide the port number each site will use.

Example: Start three Hugo servers at the same time

$ hugo server -p 50001 -s ~/mysite1
$ hugo server -p 50002 -s ~/mysite2
$ hugo server -p 50003 -s ~/mysite3

The websites started as above can be accessed at the following addresses.

  • http://localhost:50001/
  • http://localhost:50002/
  • http://localhost:50003/