Deployment to Google Compute Engine



When you start your phoenix server
I guess when creating the instance and running the

what IP is it binding to
Im not sure about this

hello_team@hello-instance:~$ netstat -lnpt | grep 8080
(No info could be read for "-p": geteuid()=1000 but you should be root.)


I’m sorry if I’m not helping. I’m still new at deployment. :sweat:


Then leave of the -p it is not that important. netstat -lnt | grep 8080 will be enough to see if something is listening on port 8080 and which IP it has bound to.

And also, please try to curl your application from the host running it. If its working there, we can put more energy in debugging the networking issue.

What do you guess with that file?

As I said, it should be in the logs.


netstat -lnt | grep 8080 not showing anything
netstat -lnt showing this

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0  *               LISTEN     
tcp        0      0    *               LISTEN     
tcp6       0      0 :::4369                 :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN 

curl is working on the server is the file that run PORT=8080 ./hello-release start
You can refer in the tutorial in section “Create a startup script”


Wait? there is nothing listening on port 8080, but a local curl works fine?


Yup. curl --help does show the list of curl options

hello_team@hello-instance:~$ curl -V
curl 7.52.1 (x86_64-pc-linux-gnu) libcurl/7.52.1 OpenSSL/1.0.2q zlib/1.2.8 libidn2/0.16 libpsl/0.17.0 (+libidn2/0.16) libssh2/1.7.0 nghttp2/1.18.1 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL 


I asked you to curl your application locally. curl localhost:8080 or something like that.

But I assume it wont work.

How exactly are you starting the application? Are you using foreground or start? If you do the former, do you close the connection/terminal or do you keep it open? You application will shut down as soon as the parent process dies. If though you use the latter, please check your logs for any error messages.


Let’s backup abit. Im starting to get confuse now.

So first, I run this command
PORT=8080 _build/prod/rel/hello/bin/ foreground
Without stopping this command I run curl localhost:8080,
It will show the HTML file for the home page

The project runs perfectly when I, PORT=8080 _build/prod/rel/hello/bin/ foreground
There were no errors, the logs from Phoenix does show normally without errors


And while it is still running, what does netstat tell you now? Are you able to access your site from external?

Muhammads-MacBook-Pro:hello Azim$ netstat -lnt | grep 8080
tcp4       0      0     TIME_WAIT  

I can access the site using localhost:8080 not the remote server


The listener is bound to the IP, This does not look like its your external IP.

Try setting http: [ip: {0, 0, 0, 0}, port: …, …] in your config to accept connections on all IPs.


Wait? Why MacBook? Is GCE running on macbooks?


Wait. You want me to run the commands in GCE or my local machine?
Hahaha. Im confuse now :sweat_smile:


Do you want to deploy to GCE or to your local laptop?


I want to deploy to GCE


Then run the commands on GCE.

I want to know on what IP the application binds to, I want to know if it works when you curl the application locally on the remote (yeah, confusing, I know)

hello_team@hello-instance:~$ netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0  *               LISTEN     
tcp        0      0    *               LISTEN     
tcp6       0      0 :::4369                 :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN  
hello_team@hello-instance:~$ curl localhost:8080
curl: (7) Failed to connect to localhost port 8080: Connection refused


Is the application currently running?

Until we got that sorted, we need to make sure that you started it manually using … foreground and then not close that terminal, but use another one to do the curl and netstat.


I’m not sure. What I know from the tutorial in “Deploying your application to a single instance” section there’s a that I added in the root of my project and the last line in the is PORT=8080 ./hello-release start and I just create an instance in GCE by running

gcloud compute instances create hello-instance \
    --image-family debian-9 \
    --image-project debian-cloud \
    --machine-type f1-micro \
    --scopes "userinfo-email,cloud-platform" \
    --metadata-from-file \
    --metadata release-url=gs://hello-releases/hello-release \
    --zone asia-southeast1-a \
    --tags http-server

In my bucket there’s hello-releases/hello-release


I do not mind the turial. We already have learnt that it for some reasons doesn’t do as we expect.

Please log in to the host, start your application in foreground mode, fire up a second SSH into that host and check curl and netstat, while you are doing this, please also observe the logs of the foreground instance. The curl should show up there.


I’m not sure how to start the application in foreground from the GCE.

hello_team@hello-instance:/$ ls
app  bin  boot  dev  etc  home  initrd.img  initrd.img.old  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  startup-LfE2ig  sys  tmp  usr  var  vmlinuz  vmlinuz.old
hello_team@hello-instance:/$ cd app/
hello_team@hello-instance:/app$ ls
cloud_sql_proxy  hello-release  tmp