tools: polymer serve --hostname doesn't work as described

Description

When I tried to serve my project locally with a specified hostname, it doesn’t work and gives me an error:

> polymer serve --hostname 'test'
Starting Polyserve...
    serving on port: 8080
    from root: L:\Dennis\Web_Development\solari

Files in this directory are available under the following URLs
    applications: http://'test':8080
    reusable components: http://'test':8080/components/solari/
error:   Promise rejection: Error: getaddrinfo ENOTFOUND 'test'
error:   Error: getaddrinfo ENOTFOUND 'test'
    at errnoException (dns.js:26:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)

This has to be a bug because I just copied the example described in the docs.

Versions & Environment

  • Polymer CLI: 0.12.0
  • node: 4.2.1
  • Operating System: Windows 10

Steps to Reproduce

  1. Create an application project: polymer init application
  2. Serve: polymer serve --hostname 'test'

Expected Results

No error is throw and I can access my application under http://test:8080

Actual Results

Opening http://test:8080 results into a DNS-Address of server test not found.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (7 by maintainers)

Commits related to this issue

Most upvoted comments

how can I change the localhost path to https://localhost:8080

@IchordeDionysos Ah of course, I forgot that local hostnames were configurable. Thanks for the clear explanation.

Try removing the quotes around test, does it work now? I get the expected results once adding test to my /etc/hosts files and running the following:

polymer serve --hostname test
Starting Polyserve...
    serving on port: 8080
    from root: /Users/fschott/Code/todo-polymer

Files in this directory are available under the following URLs
    applications: http://test:8080
    reusable components: http://test:8080/components/todo-polymer/

I created a pull request here: https://github.com/Polymer/docs/pull/1703

@IchordeDionysos You’ll have to first let your computer know about that hostname. This can be done by adding an entry to your hosts file (Linux/Unix/OS X: /etc/hosts, Windows: C:\Windows\System32\Drivers\etc\hosts):

# ip         hostname
127.0.0.1    test
127.0.0.1    project project.local # you can also add multiple names

This way the name you’re trying to listen to also resolves to an IP which is essential.

@FredKSchott test is a valid hostname to Node so long it resolves to an IP. localhost is no different. You will find that if you remove the line defining localhost from your /etc/hosts file (which usually comes pre-filled with any modern OS), it will no longer resolve either – just like test does.