Hapi: Error: listen EADDRNOTAVAIL when starting hapi server with foreman

Created on 23 Jan 2013  路  2Comments  路  Source: hapijs/hapi

hapi is unable to start up when using foreman. It is unable to use the port that foreman starts up when accessed by process.env.PORT.

var server = new Hapi.Server(process.env.PORT);

Since this is the only way to deploy to heroku.com, this is important to get working.

non issue

Most helpful comment

I created a sample hapi-heroku app to demonstrate how to use hapi on heroku.

The hapi server constructor expects that the port is a number. Therefore, you will need to convert the string process.env.PORT to a number. Also, if a host is not provided hapi will default to 'localhost', so you will need to specify a host. In hapi-heroku the constructor is (+process.env.PORT, '0.0.0.0')

All 2 comments

Thanks. We'll look into it.

I created a sample hapi-heroku app to demonstrate how to use hapi on heroku.

The hapi server constructor expects that the port is a number. Therefore, you will need to convert the string process.env.PORT to a number. Also, if a host is not provided hapi will default to 'localhost', so you will need to specify a host. In hapi-heroku the constructor is (+process.env.PORT, '0.0.0.0')

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mahnunchik picture mahnunchik  路  4Comments

taoeffect picture taoeffect  路  3Comments

hueniverse picture hueniverse  路  4Comments

RohovDmytro picture RohovDmytro  路  4Comments

DrMabuse23 picture DrMabuse23  路  5Comments