7

I'm using Eve to create a REST API for MongoDB. It's all working fine, except for the fact that I can't reach the API from any other computer (in the same network), or even a different URL (e.g.: if I set SERVER_NAME = 'localhost:29000', I will not be able to reach the API with 127.0.0.1 and vice versa).

I've been looking around for hours, and I can't seem to find an answer. I also tried other REST API's for MongoDB like Kule, and they seem to work just fine, but they don't have as many options as Eve has.

Timon
  • 362
  • 4
  • 10
  • Try binding the socket to `0.0.0.0` instead of `127.0.0.1` - the former means "all interfaces", the latter will bind it on localhost only. – Lukas Graf Jan 09 '14 at 22:42
  • Sadly, it didn't work. The strange thing is though, that it always says: "Running on http://127.0.0.1:29000", regardless of what IP address I fill in (the port does change). – Timon Jan 09 '14 at 22:45
  • Eve's `SERVER_NAME` seems to be based on the configuration variable by the same name from Flask: See "More on server name" below the table in the [Flask Configuration docs](http://flask.pocoo.org/docs/config/#builtin-configuration-values). So it's really just for the name (hostname / subdomain handling) - the actual network interfaces it binds to therfore are probably determined by the server that runs the WSGI application. How are you serving your application? – Lukas Graf Jan 09 '14 at 23:02
  • If you're just doing the `app = Eve(); app.run()` from the quickstart example, try `app.run(host='0.0.0.0')` and leave the server name empty (`SERVER_NAME = ''`) - I've never used Eve, but from what I understand about how its built that should work. – Lukas Graf Jan 09 '14 at 23:11
  • Wow, that worked! I really don't know how to thank you. – Timon Jan 09 '14 at 23:17

1 Answers1

11

Eve's SERVER_NAME seems to be based on the configuration variable by the same name from Flask: See "More on server name" below the table in the Flask Configuration docs. So it's really just for the name (hostname / subdomain handling) - the actual network interfaces it binds to therfore are probably determined by the server that runs the WSGI application.

If you're just doing the

app = Eve()
app.run()

from the quickstart example, try

app.run(host='0.0.0.0')

instead and leave the server name empty (SERVER_NAME = '').

I've never used Eve, but from what I understand about how it's built that should work

Lukas Graf
  • 30,317
  • 8
  • 77
  • 92
  • 2
    +1 for reminding me to add a `host=0.0.0.0` note to the quickstart example. Had other people face the same kind of issue before. – Nicola Iarocci Jan 10 '14 at 06:23
  • 1
    Other than that, docs are excellent from what I've been. Definitely will keep Eve in mind for the future :) – Lukas Graf Jan 10 '14 at 06:43
  • I've been digging the web for several hours looking for issues related to flask. I didn't expect to be a flask-eve issue.You saved me – vladblindu Aug 22 '16 at 17:47