# Connect Kotlin to mysql server on localhost

**URL:** <https://discuss.kotlinlang.org/t/connect-kotlin-to-mysql-server-on-localhost/16155>\
**Category:** Android\
**Created:** [January 31, 2020, 10:16am UTC](https://discuss.kotlinlang.org/t/connect-kotlin-to-mysql-server-on-localhost/16155 "2020-01-31T10:16:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkmazibuko.mazibuko](https://avatars.discourse-cdn.com/v4/letter/t/cab0a1/32.png) [@tkmazibuko.mazibuko](https://discuss.kotlinlang.org/u/tkmazibuko.mazibuko)\
**Post date:** [January 31, 2020, 10:16am UTC](https://discuss.kotlinlang.org/t/connect-kotlin-to-mysql-server-on-localhost/16155/1 "2020-01-31T10:16:37Z")

</div>

I have tired using different methods of connecting my android App written in Kotlin to a localhost of mysql server but it’s not working…any suggestions?

---

<div class="post-metadata">

**Author:** ![fvasco](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/fvasco/32/1961_2.png) [@fvasco](https://discuss.kotlinlang.org/u/fvasco)\
**Post date:** [January 31, 2020, 11:45am UTC](https://discuss.kotlinlang.org/t/connect-kotlin-to-mysql-server-on-localhost/16155/2 "2020-01-31T11:45:31Z")

</div>

Try `localtest.me` instead of `localhost` 😉

Edit: Maybe you should set the MySql server ip, is localhost the Android device?

---

<div class="post-metadata">

**Author:** ![tkmazibuko.mazibuko](https://avatars.discourse-cdn.com/v4/letter/t/cab0a1/32.png) [@tkmazibuko.mazibuko](https://discuss.kotlinlang.org/u/tkmazibuko.mazibuko)\
**Post date:** [January 31, 2020, 12:17pm UTC](https://discuss.kotlinlang.org/t/connect-kotlin-to-mysql-server-on-localhost/16155/3 "2020-01-31T12:17:04Z")

</div>

[localtest.me](http://localtest.me) doesn’t work. Am running the App on an android emulator. The database is on a different machine.

---

<div class="post-metadata">

**Author:** ![SackCastellon](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sackcastellon/32/4553_2.png) [@SackCastellon](https://discuss.kotlinlang.org/u/SackCastellon)\
**Post date:** [January 31, 2020, 12:50pm UTC](https://discuss.kotlinlang.org/t/connect-kotlin-to-mysql-server-on-localhost/16155/4 "2020-01-31T12:50:52Z")

</div>

If the database is on a different machine you will have to use the IP of that machine, `localhost` refers to the current machine.
