Skip to content

new project, get undefined as hostname #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ralyodio opened this issue Apr 26, 2014 · 9 comments
Closed

new project, get undefined as hostname #205

ralyodio opened this issue Apr 26, 2014 · 9 comments

Comments

@ralyodio
Copy link

Express server listening on undefined:9000, in development mode

and app crashes right away when running grunt serve

Running "express:dev" (express) task
Starting background Express server
debugger listening on port 5858
Express server listening on undefined:9000, in development mode

Running "open:server" (open) task

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: failed to connect to [localhost:27017]
    at null.<anonymous> (/Users/user/projects/offsite/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:553:74)
    at EventEmitter.emit (events.js:106:17)
    at null.<anonymous> (/Users/user/projects/offsite/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
    at EventEmitter.emit (events.js:98:17)
    at Socket.<anonymous> (/Users/user/projects/offsite/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:512:10)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:440:14
    at process._tickCallback (node.js:415:13)

Running "watch" task
@bogini
Copy link

bogini commented Apr 26, 2014

Make sure you're running MongoDB.

After installing it, run mongod then grunt serve

@ralyodio
Copy link
Author

that was it. thanks.

@krisalexander200
Copy link

@ibeitia i built my project without mongo (which I think was a prompt question at the beginning of the generator questions, and i said no to Mongo), because the application requires no database.

I get the undefined error when starting the application. What would be the right way to handle the issue in this scenario?

@timmaybrown
Copy link

mongod is running, but no matter what I do I still get this error of:

 Express server listening on undefined:9000, in development mode
Running "serve" task

Running "clean:server" (clean) task
Cleaning .tmp...OK

Running "bower-install:app" (bower-install) task

Running "concurrent:server" (concurrent) task

    Running "compass:server" (compass) task
    directory .tmp/styles/ 
       create .tmp/styles/main.css (0.014s)
    Compilation took 0.014s

    Done, without errors.


    Execution Time (2014-05-21 05:13:28 UTC)
    compass:server  450ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 99%
    Total 454ms

Running "autoprefixer:dist" (autoprefixer) task
Prefixed file ".tmp/styles/main.css" created.

Running "express:dev" (express) task
Starting background Express server
debugger listening on port 5858
Express server listening on undefined:9000, in development mode

Running "open:server" (open) task
finished populating things
db connection open
finished populating users

Running "watch" task
Waiting...

This is a brand new project with fresh install of the generator. Not sure what i'm missing here...

@zfarrell
Copy link
Contributor

@chair9design - are you able to access the site (i.e. http://localhost:9000/) once the server starts?

The undefined in Express server listening on undefined:9000, in development mode is a bug, but I believe it's only an issue with this log message, not an issue with starting the server.

Let me know if this assumption is wrong, and we can continue to debug.

@timmaybrown
Copy link

adding it to all.js seemed to do the trick for me, but like you said it doesn't seem to be necessary at the same time, because once I got past the undefined:9000 error, the conflict I ran into next was the fact that I also had php-fpm listening on port 9000 which was causing this error... http://stackoverflow.com/questions/16827987/expressjs-throw-er-unhandled-error-event

I found what was running on port 9000 by running this command.
sudo lsof -i :9000

Then confirmed nothing was running on 3000 by changing the above command to:

sudo lsof -i :3000

Once I new 3000 was a safe port, I changed the port to 3000 in my grunt file's express options, as well as, the all.js exports definition
port: process.env.PORT || 3000,

Now all is well and seeing 'Allo, 'Allo ! ... hopefully this helps someone else out.

@timmaybrown
Copy link

see above, but to directly answer your question about the server running despite the error message, the answer was no, but that seems to be primarily because I'm running php-fpm on port 9000 so I can reverse proxy some php sites via NGINX. Once I switched the port the server started up. The console log still says undefined, but the app started up once the port was changed, so your commit seem like it will fix the console.log in the server.js file on app start.

@ralyodio
Copy link
Author

In ./config/development.js add this line:

ip: 'localhost'

that should fix the problem.

@timmaybrown
Copy link

adding ip: 'localhost' was the first route I went, but that didn't fix the issue only because port 9000 wasn't free since php-fpm was already listening on this port otherwise simply adding the ip property to the ./config/development.js file should have done the trick. But in all actuality, this isn't even needed because the app starts without it, it's just that there is an undefined logged value on app startup in server.js when it's not added to development.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants