Each test is failing with the following error:
error: Error connecting to server under test!
````
Despite the api endpoint is set to `http://localhost:8000` , the api calls are sent to `http://127.0.0.1:8000`.
Running a web server on `127.0.0.1` instead of `localhost` solves the problem.
#### What command line options do you use?
$ dredd
#### What is in your `dredd.yml`?
```yaml
reporter: apiary
custom:
apiaryApiKey: *******
apiaryApiName: ********
dry-run: null
hookfiles: './hooks.php'
language: 'bin/dredd-hooks-php'
sandbox: false
server:
server-wait: 3
init: false
names: false
only: []
output: []
header: []
sorted: false
user: null
inline-errors: false
details: false
method: []
color: true
level: info
timestamp: false
silent: false
path: []
hooks-worker-timeout: 5000
hooks-worker-connect-timeout: 1500
hooks-worker-connect-retry: 500
hooks-worker-after-connect-wait: 100
hooks-worker-term-timeout: 5000
hooks-worker-term-retry: 500
hooks-worker-handler-host: localhost
hooks-worker-handler-port: 61321
config: ./dredd.yml
blueprint: api.apib
endpoint: 'http://localhost:8000/api/v1'
dredd --version output?dredd v2.2.5 (Darwin 15.6.0; x64)
dredd --level=debug uncover something?debug: Evaluating results of transaction execution #1: Authorisation > Logout > Logout
debug: No emission of test data to reporters { Error: connect ECONNREFUSED 127.0.0.1:8000
at Object.exports._errnoException (util.js:1028:11)
at exports._exceptionWithHostPort (util.js:1051:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 8000 }
Thanks for filing this! I've bumped into a similar problem when working on Windows support, but it's clear from your logs that you're using macOS. This needs tests and further investigation. Are you sure your computer correctly resolves localhost to an IP address?
@karpilin Could you please verify localhost is directed to 127.0.0.1 in your /etc/hosts file?
@karpilin I think this might be the problem you're experiencing: https://github.com/apiaryio/dredd/issues/586
@honzajavorek thanks for looking at it.
here hosts file:
```
$ cat /etc/hosts
#
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost ```
@karpilin Thanks! How does the command, which you use to run the server, look like? Or maybe you use standalone server, such as Apache?
@honzajavorek I run symfony build-in server
$ bin/console s:r localhost:8000
[OK] Server running on http://localhost:8000
// Quit the server with CONTROL-C.
PHP 5.6.29 Development Server started at Wed Mar 15 11:20:18 2017
Listening on http://localhost:8000
Document root is ***
Press Ctrl-C to quit.
Same problem here! I use server: 'php -S 127.0.0.1:3000 -t public'
@Pablodotnet @karpilin So you say this is not related to 127.0.0.1 vs. localhost routing? The 127.0.0.1 doesn't work as well? 😞
@honzajavorek it actually DOES work when I start a php server on 127.0.0.1 instead of localhost.
the problem is that despite the api endpoint is set to http://localhost:8000 , the api calls are sent to http://127.0.0.1:8000.
Then I think this is really the same issue as #586. localhost is just a placeholder for an IP address, but the problem is, in IPv4 the meaning of the placeholder is different then in IPv6.
From what you describe, it seems the php server resolves the word localhost to the IPv6 address (::1), while Dredd resolves localhost to the IPv4 address (127.0.0.1). That's why it works when you force the php server to the IPv4 address.
I'm merging the two issues together. In the https://github.com/apiaryio/dredd/issues/586#issuecomment-286123492 I proposed several solutions. Feel free to comment on what you think would be the best.
hi @honzajavorek
can we connect to public api endpoint instead of local host using dredd?
Hello @sajantha, absolutely! Provided the server location will use valid URL scheme, it will work as expected.
thanks @michalholasek ,but sorry i am completely new to this. Can u pls give me the example of a valid URL scheme.
The end point i tried to connect is a aws one which somewhat looks like this xxxxxxx.xxxxxxx-xx.eu-west-1.amazonaws.com .Is it a valid call
In the context of server location it is protocol://hostname, eg. https://example.com/. Add a protocol (I presume you are using http, so http://xxxxxxx.xxxxxxx-xx.eu-west-1.amazonaws.com) and it will be valid server location.
Thanks michal
On Thu, Apr 19, 2018, 7:50 PM Michal Holasek notifications@github.com
wrote:
In the context of server location it is protocol://hostname, eg.
https://example.com/. Add a protocol (I presume you are using http, so
http://xxxxxxx.xxxxxxx-xx.eu-west-1.amazonaws.com) and it will be valid
server location.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/apiaryio/dredd/issues/721#issuecomment-382754805, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AYH6zn0O8lqeEFp-Wlg1IHk6tztNmqWGks5tqJ0ogaJpZM4MLS5q
.
In both of the cases using 127.0.0.1 and localhost, not working.
Here are the config file details
module.exports = {
port: 8000,
dbUser: 'XXXX',
dbPassword: 'XXXX',
dbHost: 'localhost',
db: 'XXXXX',
serverURL: 'http://127.0.0.1:8000'
}
Error: connect ECONNREFUSED 127.0.0.1:8000
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1170:14)
@arpitbhatt027 Do other clients work with the same address? Like browser, curl
@honzajavorek yes
Could you please file a new issue with the whole Dredd output with --loglevel=debug? Thanks!
I have the same error. And I forgot to on my wamp server. Thanks :)
Most helpful comment
@honzajavorek it actually DOES work when I start a php server on
127.0.0.1instead oflocalhost.the problem is that despite the api endpoint is set to
http://localhost:8000, the api calls are sent tohttp://127.0.0.1:8000.