yesod init && yesod devel fails with "getAddrInfo: does not exist"

285 views
Skip to first unread message

Steffen Jost

unread,
Dec 11, 2014, 8:29:09 AM12/11/14
to yeso...@googlegroups.com
Running yesod devel on a freshly initialized project results in the error message:
Devel application launched: http://localhost:3000
devel
.hs: getAddrInfo: does not exist (Name or service not known)

Just to be sure, I did a fresh install of GHC, deleting .ghc and .cabal, and followed the instructions on the Yesod homepage under "Stackage Server". I just issued the commands
yesod init

cd foo && cabal install -j --enable-tests --max-backjumps=-1 --reorder-goals && yesod devel
with answering "Project name: foo" and database=s.

Googling led to a much earlier discussion in this google group about this error, but the advice there is outdated, as settings.yml already contains the line
host:           "_env:HOST:*4" # any IPv4 host
as expected. Changing *4 to * does not help either (I am on an IPv4-only network anyway).


> ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.3

> yesod version
yesod version
yesod-bin version: 1.4.1


Michael Snoyman

unread,
Dec 11, 2014, 12:01:33 PM12/11/14
to yeso...@googlegroups.com
Can you report the result of `yesod devel --disable-reverse-proxy`?

--
You received this message because you are subscribed to the Google Groups "Yesod Web Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yesodweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steffen Jost

unread,
Dec 11, 2014, 3:17:28 PM12/11/14
to yeso...@googlegroups.com
I get the same error, the only difference being that I do not even see the refreshing "application isn't built" page at localhost:3000 that I see with yesod devel:

> yesod devel --disable-reverse-proxy
Yesod devel server. Press ENTER to quit
Resolving dependencies...
Configuring foo-0.0.0...
Rebuilding application... (using cabal)
Starting development server...
Starting devel application

Michael Snoyman

unread,
Dec 11, 2014, 3:42:08 PM12/11/14
to yeso...@googlegroups.com
Interesting. What OS are you on? And can you try running a minimal Warp application[1] and see if that works?

[1] https://github.com/yesodweb/wai/tree/master/wai#getting-started
--

geoff

unread,
Dec 11, 2014, 3:50:39 PM12/11/14
to yeso...@googlegroups.com

Can you also do


echo $HOST

ping $HOST

Steffen Jost

unread,
Dec 11, 2014, 3:52:59 PM12/11/14
to yeso...@googlegroups.com
I am on a fresh install of openSUSE 13.2 Linux.

Yes, the minimal example works perfectly fine, eg. FPComplete, Yesod Tutorial, Part1 downloaded to a local file called YesodMinimal.hs works as follows:
> ghc -O2 YesodMinimal.hs                                       
[1 of 1] Compiling Main             ( YesodMinimal.hs, YesodMinimal.o )                                      
Loading package ghc-prim ... linking ... done.                                                               
Loading package integer-gmp ... linking ... done.                                                            
Loading package base ... linking ... done.                                                                   
Loading package old-locale-1.0.0.6 ... linking ... done.                                                     
Loading package array-0.5.0.0 ... linking ... done.                                                          
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package time-1.4.2 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package bytestring-0.10.4.0 ... linking ... done.
Loading package text-1.1.1.3 ... linking ... done.
Loading package hashable-1.2.2.0 ... linking ... done.
Loading package scientific-0.3.3.3 ... linking ... done.
Loading package attoparsec-0.12.1.2 ... linking ... done.
Loading package dlist-0.7.1 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package mtl-2.1.3.1 ... linking ... done.
Loading package syb-0.4.2 ... linking ... done.
Loading package pretty-1.1.1.1 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package unordered-containers-0.2.5.1 ... linking ... done.
Loading package primitive-0.5.4.0 ... linking ... done.
Loading package vector-0.10.12.2 ... linking ... done.
Loading package aeson-0.8.0.2 ... linking ... done.
Loading package auto-update-0.1.2 ... linking ... done.
Loading package blaze-builder-0.3.3.4 ... linking ... done.
Loading package blaze-markup-0.6.1.1 ... linking ... done.
Loading package blaze-html-0.7.0.3 ... linking ... done.
Loading package case-insensitive-1.2.0.1 ... linking ... done.
Loading package cereal-0.4.1.0 ... linking ... done.
Loading package base64-bytestring-1.0.0.1 ... linking ... done.
Loading package byteable-0.1.1 ... linking ... done.
Loading package securemem-0.1.4 ... linking ... done.
Loading package crypto-cipher-types-0.0.9 ... linking ... done.
Loading package cipher-aes-0.2.9 ... linking ... done.
Loading package unix-2.7.0.1 ... linking ... done.
Loading package crypto-random-0.0.8 ... linking ... done.
Loading package cprng-aes-0.6.1 ... linking ... done.
Loading package entropy-0.3.4.1 ... linking ... done.
Loading package tagged-0.7.3 ... linking ... done.
Loading package crypto-api-0.13.2 ... linking ... done.
Loading package filepath-1.3.0.2 ... linking ... done.
Loading package directory-1.2.1.0 ... linking ... done.
Loading package setenv-0.1.1.1 ... linking ... done.
Loading package skein-1.0.9.1 ... linking ... done.
Loading package clientsession-0.9.1.1 ... linking ... done.
Loading package exceptions-0.6.1 ... linking ... done.
Loading package base-unicode-symbols-0.2.2.4 ... linking ... done.
Loading package stm-2.4.3 ... linking ... done.
Loading package transformers-base-0.4.3 ... linking ... done.
Loading package monad-control-0.3.3.0 ... linking ... done.
Loading package lifted-base-0.2.2.1 ... linking ... done.
Loading package mmorph-1.0.4 ... linking ... done.
Loading package resourcet-1.1.3 ... linking ... done.
Loading package nats-1 ... linking ... done.
Loading package semigroups-0.16 ... linking ... done.
Loading package void-0.7 ... linking ... done.
Loading package conduit-1.2.3 ... linking ... done.
Loading package parsec-3.1.7 ... linking ... done.
Loading package network-2.5.0.0 ... linking ... done.
Loading package process-1.2.0.0 ... linking ... done.
Loading package random-1.0.1.1 ... linking ... done.
Loading package zlib-0.5.4.1 ... linking ... done.
Loading package streaming-commons-0.1.7 ... linking ... done.
Loading package conduit-extra-1.1.4.2 ... linking ... done.
Loading package data-default-class-0.0.1 ... linking ... done.
Loading package data-default-instances-base-0.0.1 ... linking ... done.
Loading package data-default-instances-containers-0.0.1 ... linking ... done.
Loading package data-default-instances-dlist-0.0.1 ... linking ... done.
Loading package data-default-instances-old-locale-0.0.1 ... linking ... done.
Loading package data-default-0.5.3 ... linking ... done.
Loading package cookie-0.4.1.4 ... linking ... done.
Loading package fast-logger-2.2.3 ... linking ... done.
Loading package http-types-0.8.5 ... linking ... done.
Loading package monad-loops-0.4.2.1 ... linking ... done.
Loading package stm-chans-3.0.0.2 ... linking ... done.
Loading package monad-logger-0.3.10.1 ... linking ... done.
Loading package mwc-random-0.13.2.2 ... linking ... done.
Loading package path-pieces-0.1.4 ... linking ... done.
Loading package safe-0.3.8 ... linking ... done.
Loading package system-filepath-0.4.12 ... linking ... done.
Loading package system-fileio-0.3.15 ... linking ... done.
Loading package shakespeare-2.0.2.1 ... linking ... done.
Loading package unix-compat-0.4.1.3 ... linking ... done.
Loading package vault-0.3.0.3 ... linking ... done.
Loading package wai-3.0.2 ... linking ... done.
Loading package ansi-terminal-0.6.2.1 ... linking ... done.
Loading package stringsearch-0.3.6.5 ... linking ... done.
Loading package byteorder-1.0.4 ... linking ... done.
Loading package easy-file-0.2.0 ... linking ... done.
Loading package binary-0.7.1.0 ... linking ... done.
Loading package old-time-1.1.0.2 ... linking ... done.
Loading package unix-time-0.3.4 ... linking ... done.
Loading package wai-logger-2.2.3 ... linking ... done.
Loading package word8-0.1.1 ... linking ... done.
Loading package wai-extra-3.0.2.2 ... linking ... done.
Loading package http-date-0.0.4 ... linking ... done.
Loading package simple-sendfile-0.2.18 ... linking ... done.
Loading package warp-3.0.4 ... linking ... done.
Loading package yesod-core-1.4.6 ... linking ... done.
Linking YesodMinimal ...
> ./YesodMinimal 
YesodMinimal: warpEnv: no PORT environment variable found
> export PORT=3000
> ./YesodMinimal 
11/Dec/2014:21:50:44 +0100 [Info#yesod-core] Application launched @(yesod-core-1.4.6:Yesod.Core.Dispatch ./Yesod/Core/Dispatch.hs:141:11)
127.0.0.1 - - [11/Dec/2014:21:50:52 +0100] "GET / HTTP/1.1" 200 - "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36"
127.0.0.1 - - [11/Dec/2014:21:50:52 +0100] "GET /favicon.ico HTTP/1.1" 404 - "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36"
127.0.0.1 - - [11/Dec/2014:21:50:56 +0100] "GET / HTTP/1.1" 200 - "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36"



Steffen Jost

unread,
Dec 11, 2014, 4:03:53 PM12/11/14
to yeso...@googlegroups.com
> echo $HOST

> ping $HOST
ping: unknown host empusa.tcs.ifi.lmu.de

Well, that hostname does not exist, as it is imaginary. I am on a Laptop, which is not meant to be reachable from the outside. Also, $HOST stays the same, regardless of the network that I am in. At the moment, I am on an entirely different network at another place.

However, I also tried export HOST="" and export HOST="localhost", but that did not help either. 

Michael Snoyman

unread,
Dec 11, 2014, 4:10:13 PM12/11/14
to yeso...@googlegroups.com
Try HOST="127.0.0.1", that should fix it. (Good catch Geoff :) )

--

geoff

unread,
Dec 11, 2014, 4:18:28 PM12/11/14
to yeso...@googlegroups.com
Steffen to understand what is going on, the new syntax here is saying that if there is an environment variable called HOST; use that; otherwise use *4.  you instead replace it with just "*4"  it should work fine.  It's not clear to me why exporting localhost as HOST wouldn't work, unless you don't have localhost in your hostfile either (ie, if ping localhost fails its the same thing)

Steffen Jost

unread,
Dec 11, 2014, 4:27:03 PM12/11/14
to yeso...@googlegroups.com
Thanks a lot! 

export HOST="127.0.0.1" does work for yesod devel
export HOST="localhost" does not work, despite ping localhost working fine.

If the error message would have provided the hostname therein, I might have realized what was happening. Otherwise I had no clue that environment variables were used at all, as the yesod quick start does not mention those either (also see the PORT variable in the code from my 3 post here, but thanks to the error message, I could help myself there).

Sorry for bothering with these trivial issues. My distribution did set that HOST variable up, I had no clue it even existed, apart from the installation asking me for a name for the machine.

Michael Snoyman

unread,
Dec 11, 2014, 4:27:11 PM12/11/14
to yeso...@googlegroups.com
That would be due to the usage of AI_NUMERICHOST[1] in the relevant code. To quote the docs:

> HostName can be either a numeric network address (dotted quad for IPv4, colon-separated hex for IPv6) or a hostname. In the latter case, its addresses will be looked up unless AI_NUMERICHOST is specified as a hint.

That's diving in pretty deep in the codebase now ;)

[1] https://github.com/fpco/streaming-commons/blob/master/Data/Streaming/Network.hs#L138

geoff

unread,
Dec 11, 2014, 4:48:57 PM12/11/14
to yeso...@googlegroups.com
Does that explain why using localhost doesn't work despite ping localhost working?

It might be better to take $HOST and $PORT out of the default config; both because typically users with the least experience in yesod are most likely to be happy with "*4" as the host and default 3000 port; and it also has the additional (slight) benefit of showing that _env_ format is optional.  or maybe even ask as a question in the init process.

Michael Snoyman

unread,
Dec 11, 2014, 5:02:56 PM12/11/14
to yeso...@googlegroups.com
I'd be OK with changing host, but we need to leave port as is, since yesod devel uses that environment variable to tell the app which port to listen on.

Steffen Jost

unread,
Dec 12, 2014, 1:48:16 AM12/12/14
to yeso...@googlegroups.com
I wonder why such a network IO error is not caught? Wouldn't it make sense to catch and retry with 127.0.0.1 if the HOST environment variable is set, but unreachable?

Michael Snoyman

unread,
Dec 12, 2014, 1:51:58 AM12/12/14
to yeso...@googlegroups.com
I don't think that would be a good idea. Yes, it would have addressed your confusion here. But for someone running a production system, it would be far more confusing as to why their app consistently binds to a specific network interface even though they tried to specify a different one.

On Fri Dec 12 2014 at 8:48:17 AM Steffen Jost <steffe...@gmail.com> wrote:
I wonder why such a network IO error is not caught? Wouldn't it make sense to catch and retry with 127.0.0.1 if the HOST environment variable is set, but unreachable?

--
You received this message because you are subscribed to the Google Groups "Yesod Web Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yesodweb+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages