Cannot connect to MongoDB error when attempting local development

default discord avatar
brandnholl
5 months ago
4

I'm currently attempting to run the "website" template locally for development. I've followed all the steps in the repo's readme but continuously get this error when running

yarn dev

in the terminal no matter what I try.

  • default discord avatar
    exo3718
    5 months ago

    You seem to not have a local mongodb running, there are a few ways to sort this out:



    The website template comes with a docker compose file, the easiest way to get started is by running

    docker compose up -d

    from the project root.



    Alternatively you can start a local mongodb separately, either native on your system or in a docker container with port 27017 exposed, just make sure the credentials match then.

  • default discord avatar
    flatcapped
    3 months ago

    Leaving this here in case anyone else needs it. In my case changing my connection string from "mongodb://localhost:27017" to "mongodb://0.0.0.0:27017" did the trick.

  • discord user avatar
    jarrod_not_jared
    Payload Team
    3 months ago

    ⬆️ this is a node v18 thing



    if runnning node 18+ you have to use

    127.0.0.0

    in place of

    localhost
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.