Skip to content
Advertisement

Unable to deploy NodeJS (Fastify app) in Azure App Service Linux

I’m stuck in deploying my fastify app on Azure app service linux. I’m using azure devops for pushing my code to app service. I’m using 8080 port for running my application and its works fine on my local. localhost screenshot

But the same code is not working on my Azure app service linux. Below are my Azure application setting variables.

JavaScript

My Fastify start code

JavaScript

Azure log stream message

JavaScript

When I navigate to /health route on my azure deployed site, I get below message azure site image

I googled a lot on this issue but no luck. And there is no straight forward docs on this issue. Can you guys guide me to resolve this issue.

Thanks.

Advertisement

Answer

Inside Docker, you should mention explicitly '0.0.0.0'. By default fastify is listening only the localhost 127.0.0.1 interface. To listen on all available IPv4 interfaces you should be modified to listen on 0.0.0.0 like so I change it to the following

JavaScript

Note

.listen binds to the local host, localhost, interface by default (127.0.0.1 or ::1, depending on the operating system configuration). If you are running Fastify in a container (Docker, GCP, etc.), you may need to bind to 0.0.0.0. Be careful when deciding to listen on all interfaces; it comes with inherent security risks. See the documentation for more information.

And make sure you have to use the recent fastify package version. Check the version in package.json file. Which follows

JavaScript

After changed in to recent version, the issue has fixed.

enter image description here

Use the Kudu log stream to see the detailed log information https://<your_app_name>.scm.azurewebsites.net/api/LogStream

Refer here

Advertisement