Google App Engine – running on a remote linux box (VPS)

So, you’ve been working on a Google App Engine project on your VPS and for some reason, when you type the following command:

dev_appserver.py <projectfolder>

it works, but when you try to access it in your browser from the client machine (your personal PC or laptop from where you’ve ssh’d into), it doesn’t work or gives you a “Connection Timed Out” error.

There are 2 things you need to check when this happens:

  1. IPTables – check whether you’ve opened up the port on which the local app server is working on
  2. App Server host name and port settings

For IPTables, you just need to make sure the correct rules are set. Since my app server will be running on port 8080, I had to check to see if that port was open or not. The ports can be checked with the following command:

┬ásudo iptables -nvL –line-numbers

If you don’t see port 8080 opened on the INPUT list, you’ll need to open it.

IPTables works from top to bottom. So, usually, the last entry is to reject everything that doesn’t fit. So, you might need to add the rule in between and for this we use the -I argument. For example, if I want to make this rule the 4th entry in my INPUT list (I have 5 rules), this can be done with the following command:

sudo iptables -I INPUT 4 -p tcp –dport 8080 -j ACCEPT

This should fix the iptables part of things.

Next, we need to fix the app server host and port values. By default app engine server runs on localhost and port 8080. Let’s change that to work with the external IP address of the Linux box and fix it to port 8080:

dev_appserver.py <projectfolder> –host myserver.com –port 8080

And now, if you visit myserver.com, it should work!

Advertisements