How to change Port number for Octopress rake preview

In this post,we are sharing a tip to change Port number for Octopress. By-default when we run the command rake preview in Octopress setup ,it runs on port number 4000 .
Here in this practical we will change the default port no. 4000 of Octopress to some other port no.

Note: Always select custom port number above well known port number (1 to 1024). If two or more application/service has same port number then it will not work properly.

To change the port number for Octopress,follow the given below steps

Step 1: First check,the port number which you have decided,should not be used by any service/application in system. To know about in used port number, run netstat command

netstat -tanp |grep new-port-number (For TCP based Protocol)

netstat -uanp |grep new-port-number (For UDP based Protocol)

Example : Here,in this example we are checking is port number 4400 free.

netstat -tanp |grep 4400 (For TCP based Protocol)

netstat -uanp |grep 4400 (For UDP based Protocol)

Step 2: Change the port number in file called Rakefile
Change Directory to path where you have saved the code of Octopress in your system.

Edit the Rakefile and replace the value in server_port = "4000" to server_port = "4400"

vi Rakefile

server_port     = "4400" 

Step 3: Now stop and start the command rake preview .
Now open the Web Browser and type the system IP address along with new port number.

example: http://ip-address:4400

See the below screenshot

Octopress Port change

Project URL : http://octopress.org/

1 thought on “How to change Port number for Octopress rake preview”

  1. hi. I am running my Octopress server remotely and was wondering if you know how to access your preview page remotely within a LAN. For example, if the hostname that your rake preview is being run on is “foo”, can you go to another computer in your network and view the preview page by typing “foo:4400” in a browser? I can’t do this and would love any insight on this. I am able to view it locally via localhost:4400 just fine however. Thank you.

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.